English 中文(简体)
Who schedules the scheduler in OS - Isn t it a chicken and egg scenario?
原标题:

Who schedules the scheduler?

Which is the first task created and how is this first task created? Isn t any resource or memory required for it? isn t like a chicken and egg scenario?

Isn t scheduler a task? Does it get the CPU at the end of each time slice to check which task needs to be given CPU?

Are there any good links which makes a person think and understand deeply all these concepts rather than spilling out some theory which needs to be byhearted?

问题回答

The scheduler is scheduled by

  • an (external) event such as an interrupt, (disk done, mouse click, timer tick)
  • or an internal event (such as the completion of a thread, the signalling by a thread that it needs to wait for something, or the signalling of a thread that it has released a resource, or a trap caused by a thread doing something illegal like division by zero)

In short, it is triggered by any event that might require that the set of tasks to be run and/or the priorities of those tasks to be reevaluated. The scheduler decides which task(s) run next, and passes control to the next task.

Typically, this "scheduling" of the scheduler is caused by the code associated with a hardware interrupt, or code associated with a system call.

While you can think of the scheduler as being a real thread, in practice it doesn t need to be implemented that way... because it is executed with higher priority than any other task. Sophisticated OSes may in fact set aside a special thread that is the scheduler, and mark it busy when the scheduler gets control. That makes it pretty, but the bogus thread isn t scheduled by the scheduler

One can have multiple schedulers: the highest priority one (e.g., the one we just described), and other schedulers which really are threads, and are run like other user tasks. Such lower priority schedulers tend to be used to manage actions which occur at much longer intervals, such as background jobs.

it is usually invoked periodically by a timed CPU interrupt





相关问题
What resources are shared between threads?

Recently, I have been asked a question in an interview what s the difference between a process and a thread. Really, I did not know the answer. I thought for a minute and gave a very weird answer. ...

Random access of multiple files and file caching

This relates to some software I ve been given to "fix". The easiest and quickest solution would make it open and read 10 random files out of hundreds and extract some very short strings for processing ...

What form is DLL & what makes it processor dependent

I know DLL contains one or more exported functions that are compiled, linked, and stored separately.. My question is about not about how to create it.. but it is all about in what form it is stored.. ...

Thread behavior on multicore machines

Does the threads of a single process run in parallel on a multi-core machine on windows XP? Is the behavior same on different windows versions (windows server editions) I have heard that only threads ...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签