In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the knowledge points of the Linux kernel real-time system". In the daily operation, I believe that many people have doubts about the knowledge points of the Linux kernel real-time system. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "what knowledge points are there in the Linux kernel real-time system?" Next, please follow the editor to study!
Background knowledge the scheduling strategy of Linux includes SCHED_FIFO and SCHED_RR and SCHED_OTHER
SCHED_FIFO (Round-robin thread scheduling policy) and SCHED_RR are "real-time" policies. Realize fixed priority real-time scheduling (fixed-priority real-time scheduling) specified by POSIX standard. Tasks that follow these strategies preempt all other tasks. Because of preemption, if they do not release CPU, it is easy to prevent some low-level tasks from being performed.
The difference between SCHED_FIFO and SCHED_RR is that SCHED_RR performs round-robin assignments in tasks of the same priority, and each task gets the same cpu time slice policy. SCHED_FIFO requires the task to actively abandon the cpu time slice.
SCHED_OTHER is a common round robin time-sharing scheduling strategy, which schedules tasks at a certain time according to other tasks running in the system.
Problems with SCHED_RR and SCHED_FIFO:
The two real-time scheduling strategies in Red Hat Enterprise Linux Real time have one main feature: until they are preempted by higher priority threads or until they "wait" (sleep/ hibernates or execute Imax O) threads will run. In the case of SCHED_RR, among threads with the same SCHED_RR priority, the operating system may preempt one thread so that another thread can execute.
The POSIX specification does not specify a policy that allows low-priority threads to get any CPU time.
This feature of real-time threads means that it is easy to write an application that occupies 100% of the CPU. At first glance, it may seem like a good idea to drain the server, but in fact, it causes a lot of problems with the operating system. The operating system is responsible for managing system-wide and CPU-based resources, and must periodically check the data structures that describe these resources and perform internal management activities on them. If the kernel is monopolized by SCHED_FIFO threads, it cannot perform housekeeping tasks, and eventually the entire system will become unstable, which may lead to a crash.
The interrupt handler runs as a thread with SCHED_FIFO priority (default: 50). A cpuxiao hao x thread with or higher strategy than an interrupt handler thread may prevent the interrupt handler from running and cause the program to wait for data sent by the interrupt, causing the program to starve to death and fail.
Red Hat / CentOS Special Strategy / Real-time throttling Mechanism
In the real-time system kernel of Red Hat Enterprise Edition, there is a real-time throttling mechanism / SCHED_FIFOSCHED_RR scheduling strategy (real-time scheduler throttling) that restricts real-time scheduling.
The Red Hat Enterprise Real-time Linux kernel comes with a protection mechanism that allows system administrators to allocate resource quotas for real-time tasks. The introduction of this quota mechanism can be regarded as a protection mechanism.
This mechanism is controlled by two parameters in the / proc file system.
/ proc/sys/kernel/sched_rt_period_us defines a time period in microseconds, which is equivalent to 100% of the bandwidth of CPU resources. The default value is 1000000 μ s (1 second). Carefully change this time period, it is dangerous if the time period is too long or too small.
/ proc/sys/kernel/sched_rt_runtime_us defines the total bandwidth available for all real-time tasks. The default value is 950000 μ s (0.95s), which is 95% of the CPU bandwidth. Setting this value to-1 means that real-time tasks can take up to 100% of CPU time. This can be configured only if the real-time task in a particular scenario is carefully designed and there are no obvious pitfalls (such as no unlimited polling cycle).
95% of the CPU time defined by the default value of the real-time adjustment mechanism, which means that 95% of the cpu time slices can be used in real-time tasks. The remaining 5% will be used for non-real-time tasks (tasks that run under a similar scheduling policy of SCHED_OTHER). It is also important to note that if a single real-time task occupies 95% of the CPU slot, the remaining real-time tasks on that CPU will not run. The remaining 5% of CPU time is used only by non-real-time tasks.
Setting the default value brings two benefits: rogue real-time tasks do not lock down the system by not allowing non-real-time tasks to run, and real-time tasks, on the other hand, have up to 95% of their CPU available time, which may maximize performance.
Smart, RT_RUNTIME_GREED.
Although the SCHED_FIFOSCHED_RR/ real-time throttling mechanism works to prevent real-time tasks from causing the system to hang, advanced users may want to allow real-time tasks to continue to run without a shortage of non-real-time tasks to avoid idle systems.
When enabled, this feature checks whether non-real-time tasks starve to death before restricting real-time tasks. If a real-time task is restricted, it immediately removes the restriction when the system is idle or at the beginning of the next cycle, whichever comes first.
RT_RUNTIME_GREED is enabled with the following command:
# echo RT_RUNTIME_GREED > / sys/kernel/debug/sched_features
To make all CPU cores have the same rt_runtime, disable the NO_RT_RUNTIME_SHARE logic:
# echo NO_RT_RUNTIME_SHARE > / sys/kernel/debug/sched_features
When these two options are set, the user will ensure that all non-RT tasks on the CPU have a certain amount of time to run, while running as many real-time tasks as possible.
At this point, the study of "what are the knowledge points of the Linux kernel real-time system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.