当前位置:网站首页>Zephyr 学习笔记2,Scheduling
Zephyr 学习笔记2,Scheduling
2022-07-04 07:16:00 【mayiQX】
第二章:调度器(Scheduling)。
内核基于优先级的调度器允许应用程序的线程共享CPU。
线程从运行状态转换为挂起或等待状态,例如通过k_sem_take()或者k_sleep()。
线程转换到就绪状态,例如使用k_sem_give()或者k_thread_start()。
处理中断后返回线程上下文,当运行的线程调用k_yield()时。
当线程主动启动一个将自身转换为挂起或等待状态的操作时,它将休眠。
协作式

抢占式


Scheduler Locking
在执行关键操作时不希望被抢占的可抢占线程可以通过调用k_sched_lock().一旦关键操作完成,可抢占线程必须调用k_sched_unlock()以恢复其正常的可抢占状态。
Thread Sleeping
k_sleep()
k_wakeup()
线程可以调用k_busy_wait()来执行繁忙等待,该等待将其处理延迟指定的时间段,而不会将CPU放弃给另一个就绪线程。
CPU Idling
static k_sem my_sem;
void my_isr(void *unused)
{
k_sem_give(&my_sem);
}
void main(void)
{
k_sem_init(&my_sem, 0, 1);
/* wait for semaphore from ISR, then do related work */
for (;;) {
/* wait for ISR to trigger work to perform */
if (k_sem_take(&my_sem, K_NO_WAIT) == 0) {
/* ... do processing */
}
/* put CPU to sleep to save power */
k_cpu_idle();
}
}边栏推荐
- [Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
- 输入年份、月份,确定天数
- tornado项目之路由装饰器
- 【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
- Check and display one column in the known table column
- Chapter 1 programming problems
- 响应式移动Web测试题
- Solution of running crash caused by node error
- [MySQL transaction]
- BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
猜你喜欢

Experience installing VMware esxi 6.7 under VMware Workstation 16

How notepad++ counts words

The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native

关于IDEA如何设置快捷键集

NLP literature reading summary
![[Flink] temporal semantics and watermark](/img/4d/cf9c7e80ea416155cee62cdec8a5bb.jpg)
[Flink] temporal semantics and watermark

Selenium driver ie common problem solving message: currently focused window has been closed

Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes

Set JTAG fuc invalid to normal IO port

CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
随机推荐
移动适配:vw/vh
用于压缩视频感知增强的多目标网络自适应时空融合
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
The important role of host reinforcement concept in medical industry
Responsive mobile web test questions
MySQL 45 lecture learning notes (XIV) count (*)
ABCD four sequential execution methods, extended application
If there are two sources in the same job, it will be reported that one of the databases cannot be found. Is there a boss to answer
[Mori city] random talk on GIS data (I)
Selenium ide plug-in download, installation and use tutorial
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
大厂技术专家:架构设计中常用的思维模型
[kubernetes series] kubesphere is installed on kubernetes
How notepad++ counts words
[untitled] notice on holding "2022 traditional fermented food and modern brewing technology"
leetcode825. Age appropriate friends
MySQL storage engine
MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
How to input single quotation marks and double quotation marks in latex?
There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method