当前位置:网站首页>Zephyr 學習筆記2,Scheduling
Zephyr 學習筆記2,Scheduling
2022-07-04 07:17: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();
}
}边栏推荐
- Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
- Unity 从Inspector界面打开资源管理器选择并记录文件路径
- 用于压缩视频感知增强的多目标网络自适应时空融合
- Cervical vertebra, beriberi
- Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
- 果果带你写链表,小学生看了都说好
- what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
- Literature collation and thesis reading methods
- Selection (023) - what are the three stages of event propagation?
- The final week, I split
猜你喜欢

【Kubernetes系列】Kubernetes 上安装 KubeSphere

MySQL 45 lecture learning notes (VII) line lock

Campus network problems

Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg

响应式移动Web测试题

Selenium driver ie common problem solving message: currently focused window has been closed
![[Valentine's day] - you can change your love and write down your lover's name](/img/ab/402872ad39f9dc58fd27dd6fc823ef.jpg)
[Valentine's day] - you can change your love and write down your lover's name
![SQL foundation 9 [grouping data]](/img/8a/a72941d8c3413316b063033a1b5038.jpg)
SQL foundation 9 [grouping data]

Knowledge payment applet dream vending machine V2

Summary of MySQL common judgment functions!! Have you used it
随机推荐
Novel website program source code that can be automatically collected
js 常用时间处理函数
Splicing plain text into JSON strings - easy language method
The difference between synchronized and lock
Selenium ide plug-in download, installation and use tutorial
Directory of tornado
MySQL 45 lecture learning notes (XIV) count (*)
Blue Bridge Cup Quick sort (code completion)
[MySQL transaction]
同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
MySQL 45 learning notes (XI) how to index string fields
2022-021ARTS:下半年开始
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
关于IDEA如何设置快捷键集
2022年6月小结
MySQL 45 lecture learning notes (VI) global lock
在已經知道錶格列勾選一個顯示一列
rapidjson读写json文件
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg