当前位置:网站首页>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();
}
}边栏推荐
- Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
- A new understanding of how to encrypt industrial computers: host reinforcement application
- Selection (022) - what is the output of the following code?
- [Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
- Latex中的单引号,双引号如何输入?
- How can the old version of commonly used SQL be migrated to the new version?
- [network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
- Rhcsa day 3
- Master-slave replication principle of MySQL database
- 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
猜你喜欢

tornado项目之路由装饰器

uniapp小程序分包

Responsive mobile web test questions

Master-slave replication principle of MySQL database

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
![[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph](/img/5e/7ce21dd544aacf23b4ceef1ec547fd.png)
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph

MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0

Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown

Data double write consistency between redis and MySQL

The final week, I split
随机推荐
MySQL 45 lecture learning notes (XIV) count (*)
Set JTAG fuc invalid to normal IO port
Electronic Association C language level 1 34, piecewise function
The important role of host reinforcement concept in medical industry
leetcode825. Age appropriate friends
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
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
Industrial computer anti-virus
Literature collation and thesis reading methods
Data double write consistency between redis and MySQL
About how idea sets up shortcut key sets
How to share the source code anti disclosure scheme
Electronic Association C language level 1 35, bank interest
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
Experience installing VMware esxi 6.7 under VMware Workstation 16
Lottery system test report
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Mobile adaptation: vw/vh
The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)