![]() The priority to use is obtained from the first command line argument. The only difference between them is that they setup different scheduling policies. All these programs are just a while(1) loop to simulate a busy loop. To move on to the next part of our study, compile the following programs. Real-time scheduling policy has two sub-types, round-robin and first-in first-out, identified by SCHED_RR and SCHED_FIFO. We have two categories of scheduling policies. If you are using pthread APIs, it is recommended that you use the pthread_ variants of these APIs. Some of the above APIs also have POSIX equivalents. sched_rr_get_interval() - get the SCHED_RR interval for the named process.sched_get_priority_max/min - get static priority range.sched_getparam()/sched_setparam() - set and get scheduling parameters.sched_getscheduler()/sched_setscheduler() - set and get scheduling policy/parameters.getpriority()/setpriority() - get/set program scheduling priority.nice() - Change process priority of a normal process (SCHED_OTHER).Take a look at the manual pages for the following scheduling related system calls. SCHED_OTHER only has a "niceness" attached to it.Ī higher value will always prempt a lower value of priority. SCHED_FIFO and SCHED_RR, the realtime scheduling policies use priorities. SCHED_OTHER is also referred to as "normal". SCHED_OTHER, which is the default supports only the value of 0. We see that SCHED_FIFO and SCHED_RR priorities allow priorities from 1 to 99. The output of the program is added as a comment in the above link. This program prints out the range of priorities supported by the different scheduling types. You can find these defines in /usr/include/bits/sched.h. GNU also adds SCHED_BATCH and SCHED_IDLE scheduling types. The behaviour of these three types are explained in the link above. There are three scheduling types supported by Linux. ![]() This link to the man page of the sched_setscheduler call gives you the information your need. There are resources aplenty on the web explaining the different types of scheduling on Linux and their properties. I really miss features like tables and the ability to embed source code. Note to Linked-In: After writing this document, I have come to realize that this medium is not very suitable for technical content. The behaviour of the examples assume that you have only one core. Setup the virtual machine to use only 1 CPU. You will also need to be logged in as root.Īn important note. I use a minimal Debian installation on a virtual machine to ensure I don't lose anything important. Running the sample programs might make your computer unresponsive and require a hard reset. But this is beyond the scope of this discussion.Ī word of warning. There are patches that try to address this, like the CONFIG_PREMPT_RT patch. The only issue is that the scheduling latencies may not satisfy the hard real-time requirements of critical applications. There is a misconception that Linux has to be patched to provide support for real-time scheduling. Linux supports real-time scheduling out of the box. We start by understanding the differences between the different types of scheduling and trying out some examples. With these examples, we will try to understand the different Linux scheduling policies and how the selection of priorities and scheduling policy impacts the way your program runs. I include some simple examples which you can try out. Some parts of this may not be updated to the latest kernel features, but to the best of my knowledge. This document is the result of some code experiments I did some time back to learn about how scheduling on Linux works. It robs the user of the opportunity to learn about the nitty-gritty of how it all works together.Įnough reminiscing. In a way, I think it is unfortunate that Linux is now so easy to set up. I still remember the AT command sequences! Getting access to the Internet via Lynx and email with Pine was really worth all the effort required to setup my cheap dial-up modem to connect reliably to the VSNL dial-up numbers. The thrill of seeing a shell prompt on my 386 computer after days of fighting with the install was indescribable. I should say I have been fortunate to have taken part in the earlier days of Linux. I have been working on Linux right from my days as an engineering graduate. As my first post on Linked-in, I thought I should write about something close to my heart.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |