ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have a doubt about the way linux schedules processes. It is know that a new time slice is allocated to the processes only when all the processes have finished their time slices. Now consider two processes- first a vi editior(I/O bound) and second one is a processor intensive process(CPU bound). Second process runs and finishes it's quota. But the first process has still some part of the time slice left since it is an I/O bound process and doesn't require much processing. So, does it mean that untill the first process(vi editor) finishes it's time slice, the second process will be made to wait? And the wait could be indifinite as the user may not do any activity at all. So, how does the kernel prevents such situation?
if I remember well (I read about this some time ago), when the kernel needs to check if there are processes with slices left, it only checks with the processes that are actually *running*. I.e. those that are in the "ready list" or "runqueue". Processes that are blocked on I/O are put in a separate list and are *not* taken into consideration. However, when an I/O operation finishes and causes a process to be able to continue executing, that process is put in the ready list and its scheduler parameters are given a value such that it will most likely be the first process to be run next (more precisely, its number of slices is reset to its "priority" parameter). So you get the impression of having a faster computer because the "interactive" processes can react quickly to keyboard input
By the way, when all procs in the runqueue have used up their slices, and the kernel needs to hand out new slices, this is based on the "nice" value of the process, which can be changed at any time using the "renice" command.
Hi,
Thanks for the answer. Well, I had completely overlooked the point that the editor(I/O bound process) is placed in the other queue(as TASK_INTERRUPTABLE) and not on the runqueue. Well, all other points remain the same as you have told. And by default, I/O bound processes are given more priority than a CPU bound process so that they execute ahead of CPU bound process. This settles the issue. Thanx.
Of course all this only applies to the SCHED_OTHER class, there's also SCHED_FIFO and SCHED_RR (round robin) but they're almost never used. Besides they would "choke" all SCHED_OTHER processes, even the kernel threads
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.