how does preemptive kernel lead to race conditions? if a process is preempted i.e. isn't kicked out of its critical section . from my understanding race condition is when several processes try to access and manipulate resources concurrently right. I have trouble grasping the concept
Asked
Active
Viewed 390 times
1 Answers
4
A preemptive kernel can start and stop threads at any point. This means that threads that don't carefully coordinate their accesses through locks and critical sections end up in race conditions.
The other form of multithreading is cooperative multithreading, where threads can be stopped only at points where they explicitly offer to yield the processor. This helps prevent race conditions because threads are not interrupted at random unexpected points in their processing.
The downside of cooperative multithreading is that a thread written not to yield can hog the processor, and this is why most modern operating systems use preemptive multithreading rather than cooperative multithreading.

Warren Dew
- 8,790
- 3
- 30
- 44
-
The major downside of cooperative multithreading is apallingly bad I/O performance because threads cannot be made ready/running 'immediately' when the I/O they requested earlier becomes available. – Martin James Apr 06 '14 at 11:06
-
@warren thanks. so also can a nonpreemptive lead to starvation? – EI-01 Apr 07 '14 at 02:10
-
1@user3497437 Cooperative multithreading can lead to starvation of other threads when the running thread fails to yield, yes. – Warren Dew Apr 07 '14 at 05:15