LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 09-05-2007, 02:10 PM   #1
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
Pre-emptive vs. Non-pre-emptive kernel


It is clear to me how pre-emptive scheduling in user space is of benefit to efficiency. However, I do not understand why having a pre-emptive kernel would be of any particular benefit. What is a scenario in which a preemptive kernel would be much better than a nonpreemptive kernel?
 
Old 09-05-2007, 02:44 PM   #2
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
As I understand it historically, a pre-emptive kernel forcibly timeslots processes, regardless of the processes desire to continue processing. A non-preemptive kernel allows processes to utilize the processor until they are ready to give it up. In the scenario of a non-preemptive kernel, a single process could easily hog the machine's processing time, and in effect, bring the machine to a halt.

If you think of a kernel as a vehicle intersection, a preemptive kernel will have stop lights to control how much time each lane of cars may move, giving cars in opposite lanes the time they need to move also.
 
Old 09-05-2007, 05:28 PM   #3
neoAKiRAz
Member
 
Registered: Jan 2006
Location: Uruguay
Distribution: Kubuntu
Posts: 48

Rep: Reputation: 15
I'm not sure, but I think he's refering to the kind of preemption where the processor is executing kernel code and it is preempted to execute some other kernel code.

In that case I have the same doubt, but I think a possible scenario would be when the processor is executing kernel code on some process' behalf (not for example scheduling code), for example a system call, and there the processor is preempted to execute some other higher priority process' kernel code (another system call which follows its execution due to a ready I/O device, or something).

This is just a guess, so please tell me what you think...
 
Old 09-05-2007, 07:10 PM   #4
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
This is what I'm talking about: http://www.webopedia.com/TERM/m/multitasking.html
 
Old 09-05-2007, 08:21 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,806

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
Try this kernelnewbies article.
Very good site BTW.
 
Old 09-05-2007, 08:35 PM   #6
neoAKiRAz
Member
 
Registered: Jan 2006
Location: Uruguay
Distribution: Kubuntu
Posts: 48

Rep: Reputation: 15
Now I'm sure
What you're talking about is process preemption, or preemptive scheduling, and what you explain is correct. It is about how the currently running process can be preempted when a process of higher priority changes to the TASK_RUNNING state (regardless of the Mode the original process was running in). See section Process Preemption from Chapter 10 of Understanding the Linux Kernel.

But a slightly different thing is Kernel Preemption, which basically defines if the currently running process can be preempted while it is executing specifically kernel code (i.e. a system call) and switched to the kernel code of another higher priority process which becomes runnable (i.e. a process waiting inside a read() syscall waking up because the user pressed a key). You can read this from section Kernel Preemption from Chapter 5 of the same book.

And jhwilliams, in the last link you can read about how Kernel Preemption reduces dispatch latency and how this benefits some kind of processes (movie players, etc).

Learning too!
 
Old 09-05-2007, 08:41 PM   #7
neoAKiRAz
Member
 
Registered: Jan 2006
Location: Uruguay
Distribution: Kubuntu
Posts: 48

Rep: Reputation: 15
Great link syg00...
Forum threads should have spinlocks too :P
 
Old 09-05-2007, 09:06 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,806

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
Cheers - it should be noted that Ingo is about to make all this discussion moot.
Do a search on CFS - I was involved in a thread here recently.
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation Advice - pre-emptive Walton Suse/Novell 7 08-19-2007 04:20 AM
is there any way to get the configuration of an pre-compiled kernel. schatoor Linux - General 2 01-04-2004 10:12 AM
Kernel Pre patch lacerto Linux - Software 1 11-04-2003 01:31 PM
Kernel 2.5 & pre-emption Thaidog Linux - General 1 09-20-2002 02:13 AM
configuration of pre-compiled kernel sadeer Linux - Software 1 06-14-2002 07:25 AM


All times are GMT -5. The time now is 12:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration