当前位置:网站首页>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();
}
}边栏推荐
- Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
- Lottery system test report
- Literature collation and thesis reading methods
- Blue Bridge Cup Quick sort (code completion)
- [MySQL transaction]
- uniapp小程序分包
- Check and display one column in the known table column
- 两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
- Introduction to spark core components
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
猜你喜欢

Mobile adaptation: vw/vh

Implementation of ZABBIX agent active mode

Experience installing VMware esxi 6.7 under VMware Workstation 16

Technical experts from large factories: common thinking models in architecture design

Knowledge payment applet dream vending machine V2

Solution of running crash caused by node error

Bottom problem of figure

果果带你写链表,小学生看了都说好

Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction

flask-sqlalchemy 循环引用
随机推荐
Bottom problem of figure
用于压缩视频感知增强的多目标网络自适应时空融合
输入年份、月份,确定天数
响应式移动Web测试题
在已经知道表格列勾选一个显示一列
Cervical vertebra, beriberi
tornado项目之路由装饰器
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
The difference between synchronized and lock
Splicing plain text into JSON strings - easy language method
Four sets of APIs for queues
MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
rapidjson读写json文件
Introduction to spark core components
Label management of kubernetes cluster
Solution of running crash caused by node error
【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
Finishing (III) - Exercise 2
How notepad++ counts words
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and