Cheap and Secure Web Hosting Provider : See Now

[Answers] How does the OS Scheduler give/take control of HW?

, , No Comments
Problem Detail: 

Imagine a uniprocessor system with a simple operating system with non-threaded processes and basic virtual memory (paging, no segmentation, no replacement to disk, etc).

Now assume a simple preemptive scheduler, round-robin, for example.

Because it is a uniprocessor, the scheduler must hand over control of the processor momentarily for any other processes it schedules to run. How does it regain control? It can't generate interrupts, as it is not running.

I originally assumed there must be some kind of register containing the time to return control to the scheduler, and a register pointing to the location of the scheduler. But if these registers existed, what would a nonpreemptive scheduler do with them? How would the processor know the difference between a preemptive and nonpreemptive scheduler, i.e. how would it know whether to use the registers to return, or allow the process to run to completion?

Asked By : Dylan Jager-Kujawa

Answered By : Kaustabha Ray

Your idea of interrupts is correct, but not how it works. The scheduler program will not raise an interrupt.

Let's take the round robin algorithm you have mentioned. A process is going to run for a period of time and then is supposed to relinquish the CPU. How does this work? Interrupt. It is the operating system that raises this interrupt using what is called an interval timer. The interval timer is programmable and is set to the time slice value of the round robin algorithm.

Once the interrupt is raised, the time quantum for the current process expires and the control is given to the scheduler process.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/55796

3.2K people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback