当前位置:网站首页>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();
}
}
边栏推荐
- 高薪程序员&面试题精讲系列119之Redis如何实现分布式锁?
- Knowledge payment applet dream vending machine V2
- Selection (022) - what is the output of the following code?
- [network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
- Label management of kubernetes cluster
- Summary of MySQL common judgment functions!! Have you used it
- 电子协会 C语言 1级 35 、银行利息
- Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
- Literature collation and thesis reading methods
- There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
猜你喜欢
Introduction to spark core components
The final week, I split
[kubernetes series] kubesphere is installed on kubernetes
Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
Chain ide -- the infrastructure of the metauniverse
云Redis 有什么用? 云redis怎么用?
What is industrial computer encryption and how to do it
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
How notepad++ counts words
随机推荐
What is the use of cloud redis? How to use cloud redis?
Selection (022) - what is the output of the following code?
【Kubernetes系列】Kubernetes 上安装 KubeSphere
win10微软拼音输入法输入文字时候下方不出现中文提示
The most effective futures trend strategy: futures reverse merchandising
用于压缩视频感知增强的多目标网络自适应时空融合
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
The final week, I split
leetcode825. Age appropriate friends
Design of test cases
Latex中的单引号,双引号如何输入?
rapidjson读写json文件
两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
Novel website program source code that can be automatically collected
【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
在已经知道表格列勾选一个显示一列
How can the old version of commonly used SQL be migrated to the new version?
MySQL 45 learning notes (XI) how to index string fields
MySQL storage engine
Responsive - media query