LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Linux Scheduling (https://www.linuxquestions.org/questions/programming-9/linux-scheduling-193217/)

Kumar 06-14-2004 01:36 AM

Linux Scheduling
 
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?

Thanks & Regards,

nukkel 06-14-2004 02:57 AM

Hi,

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.

Cheers,
nukkel

Kumar 06-14-2004 03:39 AM

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.

nukkel 06-14-2004 04:24 AM

No problem!

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 :( :(

Greets
nukkel


All times are GMT -5. The time now is 10:42 PM.