LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-14-2004, 02:36 AM   #1
Kumar
Member
 
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Rep: Reputation: 15
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,

Last edited by Kumar; 06-14-2004 at 02:38 AM.
 
Old 06-14-2004, 03:57 AM   #2
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
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
 
Old 06-14-2004, 04:39 AM   #3
Kumar
Member
 
Registered: Sep 2003
Location: Pune, India
Distribution: Red Hat
Posts: 106

Original Poster
Rep: Reputation: 15
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.
 
Old 06-14-2004, 05:24 AM   #4
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
editing the linux cpu scheduling algo cathiejcm Linux - Software 1 11-11-2005 08:25 AM
Scheduling in Linux asurya Linux - General 5 08-31-2005 09:34 AM
linux scheduling problem lordofring Programming 2 08-30-2005 10:08 AM
switching Linux kernel I/O scheduling algorithms irfanhab Slackware 1 03-17-2005 12:53 PM
Process Scheduling in Linux Newbiegal Programming 6 10-04-2004 01:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration