当前位置:网站首页>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();
}
}
边栏推荐
- MySQL 45 lecture learning notes (XIII) delete half of the table data, and the table file size remains the same
- 【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
- MySQL 45 lecture learning notes (XIV) count (*)
- What is industrial computer encryption and how to do it
- The difference between synchronized and lock
- 云Redis 有什么用? 云redis怎么用?
- Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
- 《剑指Offer》第2版——力扣刷题
- Knowledge payment applet dream vending machine V2
- BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
猜你喜欢
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Implementation of ZABBIX agent active mode
NLP literature reading summary
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
Two years ago, the United States was reluctant to sell chips, but now there are mountains of chips begging China for help
Pangu open source: multi support and promotion, the wave of chip industry
Selenium ide plug-in download, installation and use tutorial
Splicing plain text into JSON strings - easy language method
How to share the source code anti disclosure scheme
随机推荐
Directory of tornado
The most effective futures trend strategy: futures reverse merchandising
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
Set JTAG fuc invalid to normal IO port
[FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
[FPGA tutorial case 7] design and implementation of counter based on Verilog
Redis interview question set
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
The difference between synchronized and lock
How notepad++ counts words
The important role of host reinforcement concept in medical industry
响应式——媒体查询
Flink memory model, network buffer, memory tuning, troubleshooting
Experience installing VMware esxi 6.7 under VMware Workstation 16
【Kubernetes系列】Kubernetes 上安装 KubeSphere
Rhcsa day 3
NLP-文献阅读总结
What is industrial computer encryption and how to do it
校园网络问题