【RT-Thread Reading Notes】Reflections on RT-Thread Chapters 9-12
[Copy link]
Chapter 9 1. When a thread needs to be delayed and enters a blocked state, what does the CPU do? If there are no other threads to run, RTOS will create an idle thread for the CPU, and the CPU will run the idle thread at this time. In RT-Thread, the idle thread is the thread with the lowest priority created when the system is initialized. The main body of the idle thread is to clean up some system memory. Question 1. Doesn't the CPU cycle through each thread over and over again? Why does it need to be idle? 2. Define the idle thread function Chapter 10 1. Each bit of the thread ready priority group corresponds to a priority, bit 0 corresponds to priority 0, bit 1 corresponds to priority 1, and so on. 2. Thread priority table linked list mounting situation 412953 This content is created by EEWORLD forum netizen 天命风流, if you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source. 3. The data type of the thread priority table is rt_list. Each index number corresponds to the priority of the thread. A bidirectional linked list is maintained under the index. When the thread is ready, the thread will be inserted into the linked list of the corresponding index according to the priority. Threads with the same priority will be inserted into the same linked list. Chapter 11 1. Each thread has a built-in timer. When the thread needs to be delayed, the thread will be suspended first, and then the built-in timer will be started, and the timer will be inserted into a global system timer list rt_timer_list. This global system timer list maintains a doubly linked list. Each node represents the timer of the thread that is being delayed, and the nodes are arranged in ascending order according to the delay time. 2. Initialization: rt_system_timer_init() Stop: rt_timer_stop(rt_timer_t timer) Control function: rt_timer_control(rt_timer_t timer, int cmd, void *arg) Scan: rt_timer_check(void) Chapter 12 1. When there are more than two threads at the same priority, the thread supports the time slice function, that is, we can specify the time for the thread to run continuously once, in ticks. Suppose there are two threads, thread 2 and thread 3, and their priorities are both 3. The time slice of thread 2 is 2, and the time slice of thread 3 is 3. When the thread with priority 3 is executed, thread 2 will be executed first until the time slice of thread 2 is exhausted, and then thread 3 will be executed. For the specific experimental waveform diagram, please refer to the experimental phenomenon at the end of this chapter.
|