scheduling systems

>>It is hard to demonstrate the benefits of using the yield method without being able to run some sample code on two different implementations on Java with different thread scheduling systems. Assuming that option is not available to you it is worth describing two main different scheduling systems used in operating systems.

Time slicing/preemptive

Each thread gets a set amount of CPU time for executing. Once it has used up its time with the CPU, it is removed from accessing the CPU and any other waiting Threads get a chance at CPU time. When each thread has had its chance with the CPU the cycle starts again.The beauty of this approach is that you can be confident that each thread will get at least some time executing.

Non time slicing/Cooperative

A priority system is used to decide which thread will run. A thread with the highest priority gets time with the CPU. A program under this system needs to be created in such a way that it "voluntarily" yield access to the CPU.

I was reading above staments from link

I have not understood the difference between the scheduling systems.  Which scheduling System usually works on windows, unix operating sysems and how to check, know.

Any ideas, resources, links, sample code highly appreciated. thanks in advance.
Who is Participating?
>> Which scheduling System usually works on windows, unix operating sysems and how to check, know.

All modern operating systems use the first system - preemptive multitasking.  They essentially give a process a certain amount of time that it can run (e.g. 10 ms) and then pause that process and give the next available process time to run.

Some early operating systems relied on cooperative multitasking - the second approach you listed.  Those require the writer of an application to explicitly include some sort of "yield()" statements in their code, which would cause their process to stop and give control to the next waiting process.  This isn't a great model since I could choose to write an application which never yielded and consume 100% of the CPU for my program.  Imagine if your web browser did this - Skype would never get enough time to wake up and tell you somebody was trying to call you :)

The cooperative systems were implemented back when people were first thinking about multitasking.  In the early days of DOS, computers could essentially only run one process at a time and the user needed to stop that process and explicitly switch to a new one.  It's a bit like using a game console today - where you need to take out the disc for Game A before you can play Game B.  It was only when they started to work on windowed operating systems where 2+ programs could run at once that multitasking came in and cooperative seemed the easiest to build.

Today though nobody has cooperative multitasking for desktop operating systems.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.