当前位置:网站首页>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();
}
}边栏推荐
- Technical experts from large factories: common thinking models in architecture design
- 用于压缩视频感知增强的多目标网络自适应时空融合
- 两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
- 云Redis 有什么用? 云redis怎么用?
- What is industrial computer encryption and how to do it
- Selenium driver ie common problem solving message: currently focused window has been closed
- what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
- Selection (023) - what are the three stages of event propagation?
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- Enter the year, month, and determine the number of days
猜你喜欢

BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment

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

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

Responsive mobile web test questions

Status of the thread

notepad++如何统计单词数量

Experience installing VMware esxi 6.7 under VMware Workstation 16

About how idea sets up shortcut key sets

Chain ide -- the infrastructure of the metauniverse

How to share the source code anti disclosure scheme
随机推荐
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
The final week, I split
The most effective futures trend strategy: futures reverse merchandising
移动适配:vw/vh
How can the old version of commonly used SQL be migrated to the new version?
Enter the year, month, and determine the number of days
Mobile adaptation: vw/vh
SQL foundation 9 [grouping data]
Implementation of ZABBIX agent active mode
Tar source code analysis Part 10
How to input single quotation marks and double quotation marks in latex?
Design of test cases
Selection (021) - what is the output of the following code?
Chain ide -- the infrastructure of the metauniverse
关于IDEA如何设置快捷键集
校园网络问题
Responsive - media query
Finishing (III) - Exercise 2
Summary of MySQL common judgment functions!! Have you used it
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions