2
$\begingroup$

I understand that CPU scheduling takes place on 4 circumstances listed below:

  1. When the process changes state from Running to Ready
  2. Changes state from Running to Waiting
  3. Changes state from Waiting to Ready
  4. Process Terminates

However, i notice that the CPU scheduling does not take place when Ready to running. Why is this so?

$\endgroup$
0

5 Answers 5

2
$\begingroup$

The only way that a process can go from "ready" to "running" is if the scheduler just scheduled it. Running the scheduler as soon as the process started running would mean that you'd actually be running the scheduler the whole time.

$\endgroup$
2
$\begingroup$

When a process moves from running to ready, to waiting, or to finished, it just lost the use of the CPU, a CPU is free and the scheduler has to select a new process to run.

When the scheduler selects the next process to run, it picks it from the ones in ready to move to running. It is part of the scheduling process, it doesn't trigger it's running.

$\endgroup$
1
$\begingroup$

If a process is "ready", that implies that it is ready to get scheduled (and thus executed or "run"). And only if a process is "ready", it gets scheduled.

And in what ever order the processes get scheduled, they are supposed to "run" (get executed by the CPU) in that order itself. That is the fundamental notion of scheduling processes which are "ready" to be "run" on the CPU.

I suggest, you go through, Operating System Concepts, Galvin et al. ( Ch. 5 - CPU scheduling -> 5.1.3 Preemptive Scheduling).

$\endgroup$
0
$\begingroup$

when you say a process is ready it means that it is in prime condition to be scheduled by the processor and go into the running state.

once it goes into the running state it can either go to the wait/sleep/termination,and from the wait/sleep it can go to the ready state again or as the first condition displays jump directly from the running to ready queue in case there is a FIFO or a rate monotonic scheduling.

so yes...it all depends upon the scheduler scheme...but as far as your question goes as to why there is no scheduling from the Ready->Running states..the scheduler assembles the process queue as per a scheduling algorithm and then the processor is free to execute them from the queue as the come one by one i.e like the basic of how it works.

$\endgroup$
0
$\begingroup$

A CPU does Scheduling decisions only when it doesn't know which the next process is. If the scheduler decides that process P which is currently in Ready State should start running on CPU, then why will the CPU further do the Scheduling?

Even more, When an process P goes from Ready to Running, the CPU now indulges in executing the dispatcher module (A module which is part of OS that gives control of the CPU to the process selected by the processor). The CPU should start context switching since it knows which the next process is. So, it doesn't waste it's time doing CPU Scheduling.

PS: Same is the case with "Waiting to Running".

TLDR: You're asking "Why the CPU is not solving the problem?" when in fact the CPU already has a valid solution (i.e start executing the process decided by the scheduler).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.