In order to effectively manage clock tick and ensure real-time system performance, μC / OS-II I not only adds a special system task to manage clock tick, but also uses hash hash table mechanism to further reduce the time spent on clock tick processing. This article discusses the shortcomings of μC/OS-II in clock beat management and introduces the efficient clock beat management mechanism in μC/OS-III.
In the embedded real-time operating system (RTOS), tasks can suspend their own delays by calling a delay function (such as the OSTImeDly() function in μC/OS). The task releases the CPU usage right during the delay, that is, the delayed task does not occupy valuable CPU resources. Delayed tasks are managed by the clock beat service trace. When the task delay ends and is ready to run, the clock tick service will resume the task. The clock tick service runs periodically, its operation is triggered by a periodic clock tick interrupt, and the clock tick interrupt can be generated by a hardware timer.
In μC/OS-III, the clock tick service is completed in the clock tick interrupt service routine. Each clock tick service traverses the entire task list and decrements the delay counters of all delay tasks. When the number of tasks is large, the clock tick service processing time is very long, which causes the interrupt delay time and the task delay time to become long, which affects the real-time performance of the system.
In μC/OS-III, the clock tick service is no longer completed in the clock tick interrupt service routine, but is placed in a clock tick task. Moreover, by using the 啥希散表 mechanism to manage the delay task, each clock tempo service only needs to process a very small number of delay tasks, thereby greatly reducing the time spent on the clock tempo service and improving the real-time performance of the system.
In addition, in the μC/OS series RTOS, the clock tick service not only tracks the delayed tasks, but also the waiting tasks that specify the timeout period. That is, when the specified timeout period ends, the clock tick service will resume the task even if the event waiting for the task does not occur.
Clock Beat Management Mechanism in 1 μC/OS-IIIn μC/OS-II, each clock tick service traverses the entire task list and processes each task in turn. If the delay count of the currently processed task is 0, then the task is skipped and the next task is processed; otherwise, the delay count of the current task is decremented by 1, and then it is judged whether the delay count after subtracting 1 is 0. If it is 0, it means the task delay is over or waiting for timeout. Since μC/OS-II allows other tasks to call the OSTaskSuspend() function to suspend a task that is being delayed, in this case, not only does the task delay have to wait for the other task to call the OSTaskResume() function to cancel the task. The forced suspend state allows the task to enter the ready state. Therefore, when the delay count is decremented to 0, it is also necessary to determine whether the task is forcibly suspended. The task can be put into the ready state only if the task is not forced to hang; otherwise, the delay count is set to 1 to maintain the task's delay state. The main code and comments for the μC/OS-II clock tick service function are as follows:
In μC/OS-II, since every clock tick service traverses all tasks, when the number of tasks is large, the execution time may be long. In addition, since the clock tick service function OSTImeTICk() is executed by the clock tick interrupt service routine OSTIcidSR(), when the OSTimeTick() execution time is long, the execution time of the clock tick interrupt service routine is also long. When the interrupt service routine is executed, all tasks cannot be executed. In this case, the real-time performance of the system will be poor.
Clock Beat Management Mechanism in 2 μC/OS-IIIFor the problem of μC/OS-II clock tick service, μC/OS-III mainly made two improvements: 1 clock tick task for clock tick processing; 2 clock tracing wheel for class management delay task and specified timeout Time-bound waiting task.
2.1 Clock Beat Task
In μC/OS-III, a system task, the clock tick task OS_TickTask(), has been added. This task is one of the two system tasks that will always be created in μC/OS-III. The clock tick task is responsible for processing the delay task and waiting for the specified timeout period, so that μC/OS-III puts the processing of the clock tick into the task level code. The relationship between the clock tick interrupt service routine and the clock tick task is shown in Figure 1.
Whether in μC/OS-II or in μC/OS-III, a hardware timer (or other peripheral that generates periodic interrupts) is required to generate clock tick interrupts of tens to thousands of Hz. The exact frequency at which the clock tick is interrupted depends on the performance of the processor being used and the application requirements. The higher the clock tick interrupt frequency, the higher the delay accuracy of the system and the higher the processing power requirements of the processor.
Each time a clock tick interrupt is generated, the CPU will jump to the clock tick interrupt service routine (ISR) for execution. The clock beat ISR calls the OSTimeTick() function. As mentioned earlier, the clock beat ISR of μC /OS-II also calls the OSTimeTick() function. At this point, μC/OS-II and μC/OS-III look no different, but actually μC/OS-III The OS TimeTick() function in the OS is quite different from the OSTimeTick() function in μC/OS-II. The OSTimeTick() function in μC/OS-III mainly performs the following operations: signaling the clock tick task, calling the OS_SchedRoundRobin() function, and signaling the timer task. Among them, the last two points have nothing to do with the management of the clock beat, which is not described in detail here. The streamlined OSTimeTick() function is shown in the code below, which only retains the code associated with clock beat management.
In μC/OS-III, the OSTimeTick() function does not need to traverse the task list, but only signals the clock tick task via the OSTaskSemPost() function. The clock tick task is in a state of waiting for the signal for most of the time. Each time the signal is received, the clock tick task resumes running, the OS_TiekListUpdate() function is called to process the delayed task, and then the signal waiting for the signal is entered again. Status, the code is as follows:
Compared to the clock tick management mode of μC/OS-II, μC/OS-III uses a special clock tick task to process the clock tick, which can greatly reduce the execution time of the clock tick interrupt service routine.
In order to improve the processing speed of the clock tick, μC/OS-III uses a hash hash table mechanism to manage all the tasks that are being delayed and the waiting tasks that specify the timeout period. These tasks are recorded in the TICk List. The clock beat list consists of two parts: an array called the clock beat wheel (OSCfg_TickWheel[]) and a clock beat counter (OSTickCTR), as shown in Figure 2.
Each task in the clock beat list has a delay end time or a wait timeout period, assuming TM. For example, if a task calls OSTimeDly() to delay dly clock ticks when the clock tick counter value is OSTickCtr, then the task's delay end time TM is equal to OSTickCtr+dly. Then, using the number of entries of the TM and clock beat wheel (OS_CFG_TI CK_WHEEL_SIZE), a remainder I (I = TM% OS_CFG_TICK_WHEEL_SIZE) can be obtained. Then, the time-delay task will be placed in the task list pointed to by the first entry of the clock beat roulette.
Each entry of the clock beat roulette has three members: ".NbrEntriesMax", ".NbrEntries", and ".FirstPtr". The ".FirstPtr" points to the task list corresponding to the entry, and all the delayed tasks assigned to the entry or the waiting tasks with the specified timeout period are placed in the task list. ".NbrEntries" and ".NbrEntries Max" record the current number of tasks and the maximum number of historical tasks in the task list, respectively. In the task list, the tasks are sorted according to the delay end time or the timeout period, and the tasks at the end time are ranked in front of the linked list.
By adopting the hash hash table mechanism, only the task list pointed to by a specific entry of the clock beat roulette needs to be processed every time the clock beat service is served, because the delay ends or waits for the timeout just during the clock beat service. The task must be in the task list pointed to by the entry, and the index number of the entry is equal to OSTickCtr%OS_CFG_TICK_WHEEL_SIZ E. In addition, since the tasks in the task list pointed to by each entry are sorted in the order of the delay end time and the wait timeout time limit, when the current task linked list is processed, the task can be judged from the task located at the head of the linked list. Whether the delay end time or the wait timeout period is equal to the current value of OSTickCtr. If it is equal, it indicates that the task has expired or waited for timeout, and then judge the next task; if it is not equal, it indicates that the task delay has not ended or waits for no timeout, and also indicates that the tasks behind the linked list are not It is possible that the delay ends or waits for a timeout, so the processing of the task linked list can be ended immediately.
Due to the hash hashing mechanism, the clock tick service in μC/OS-III only needs to judge the delay end time or timeout period of a very small number of tasks in most cases to see if it is equal to the current value of the clock tick counter. This is obviously much more efficient than the clock beat service that needs to traverse the entire task list in μC/OS-II.
ConclusionThe clock tick service in μC/OS-II has two shortcomings: one is to traverse the entire task list, and the other is to perform clock tick processing in the clock tick interrupt service routine. When the number of tasks in the system is large, it will affect the real-time performance of the system, which is not perfect for a real-time embedded operating system. In μC/OS-III, these two problems are well solved by adding a clock tick system task and adopting a hash hash table mechanism, which ensures the real-time performance of the system even when the number of system tasks is large.
This liquid-cooled cabinet uses stable and customized insulating oil. The circulating insulating oil can absorb the heat generated by the high-power heating equipment immersed in the oil. The final heat is transferred by the high-efficiency water-cooling device. No fans are involved in the whole process (remove the cooling fan and the power supply fan) , Oil circulation uses silent high temperature resistant oil pump, efficient water circulation heat dissipation, achieves the best energy efficiency ratio of machine and liquid cooling cabinet, quiet and stable, and brings higher benefits to your business!
4 Advantages of immersion oil cooling system
1. +50% profit
2. 80% Reduced failure rate
3. Easy to install &Safe
4. Noiseless running
No fans = no noise, more profit , less downtime & less maintenance.
immersion cooling,oil immersion cooling,immersion cooling mining,immersion cooling asic,immersion cooling s19
Shenzhen YLHM Technology Co., Ltd. , https://www.ylhm-tech.com