• Forum
  • Lounge
  • How are time slicing, multitasking kerne

 
How are time slicing, multitasking kernels implemented?

They set the PIT to generate clock interrupts every, say, 10 ms, and switch tasks whenever a clock interrupt occurs. The way they pick the task is where it gets interesting. The simplest method is just to have a queue of tasks and then go through them in order. This algorithm is called round robin. There are other, more complex algorithms that allow prioritising but still ensure that all processes get to run. One method is to have several queues where each process in each queue has the same priority, but each queue has a different one. Then you do a prioritising scheduling algorithm to select the queue and then round robin (select the next one) on the queue itself. Whenever there's nothing to do, you just switch to a default process that does nothing, to waste the CPU's time (on Windows this is what the System Idle Process does; on Linux, the init process does the job).
As chris has said, there's lots of different ways to do this, and each platform does it differently. This book does a nice job of explaining it, and describes each major platform's way. It even provides some code out of the Linux kernel.

http://www.amazon.com/Operating-System-Concepts-Abraham-Silberschatz/dp/0470128720/ref=sr_1_1?ie=UTF8&qid=1361994786&sr=8-1&keywords=operating+systems
Topic archived. No new replies allowed.