当前位置:网站首页>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();
}
}
边栏推荐
- 由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
- 响应式移动Web测试题
- Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
- Lottery system test report
- 手写简易版flexible.js以及源码分析
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
- [GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
- [Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
- Set JTAG fuc invalid to normal IO port
- Rhcsa day 3
猜你喜欢
Computer connects raspberry pie remotely through putty
What is industrial computer encryption and how to do it
Unity 从Inspector界面打开资源管理器选择并记录文件路径
Master-slave replication principle of MySQL database
用于压缩视频感知增强的多目标网络自适应时空融合
Introduction to rce in attack and defense world
MySQL 45 lecture learning notes (VII) line lock
Rhcsa the next day
电脑通过Putty远程连接树莓派
socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
随机推荐
Redis interview question set
Solution of running crash caused by node error
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
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
[FPGA tutorial case 7] design and implementation of counter based on Verilog
The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
Two years ago, the United States was reluctant to sell chips, but now there are mountains of chips begging China for help
2022-021rts: from the second half of the year
Four sets of APIs for queues
Centos8 install mysql 7 unable to start up
Check and display one column in the known table column
Transition technology from IPv4 to IPv6
Chain ide -- the infrastructure of the metauniverse
MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
Bottom problem of figure
[untitled] notice on holding "2022 traditional fermented food and modern brewing technology"
[FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
Campus network problems
How to share the source code anti disclosure scheme
NLP literature reading summary