Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse the thread scheduler in RT-Thread

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to parse the thread scheduler in RT-Thread. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

The scheduler is the core of the operating system, and its main function is to switch threads, that is, to find the thread with the highest priority from the ready list, and then execute the thread.

To implement a thread scheduler, the first question is when you need to release CPU from an infinite loop of threads. This is a scenario with different scores, such as: the thread finishes executing; the thread needs to wait for a peripheral response; the thread is executing, but the higher priority thread is ready; the thread is executing, but the thread of the same priority is ready. Different os treats these scenarios differently. As a kind of RTOS, RTT allows preemptive scheduling. So when the thread is executing, but the higher priority thread is ready, the thread scheduler should immediately actively preempt the CPU.

This leads to the second problem, how to free CPU from an infinite loop of threads. We know that the interrupt controller can interrupt the execution sequence of the program and gain control over the CPU. However, some threads do not involve interrupts. In response, the operating system uses a counter to deal with the problem. This counter is like the "heartbeat" of RTOS, waking up the thread scheduler regularly. STM32F103 provides a special peripheral SysTick for the operating system.

The third problem is how to restore the previous state of the thread after the thread switch. This requires each thread to be assigned a proprietary thread stack to store the thread's parameters when the thread switches.

On how to parse the thread scheduler in RT-Thread is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report