CPU Scheduling

CPU Scheduling

CPU Scheduling – In case of single processor only one process can run at a time and other processes waits for until the processor free and can be rescheduled. The main objective of multiprogramming is to have some process running all the time to maximize the CPU utilization. In the single processor CPU sit idle whenever process request for the I/O completion all this waiting is wastage of time. To overcome this problem several processes are kept in memory at a time. Whenever one process has to wait the operating system assign another process to the CPU. This kind of scheduling is fundamental OS functions almost all the computer resources are schedule before use.

CPU and I/O Burst Cycle

The CPU’s scheduling success depends on an observed property of processes.

  • The process execution includes a cycle of CPU execution and I/O wait process alternate b/w these two states.
  • Execution of process is being with CPU burst which is followed by an I/O burst that is followed by CPU burst then other I/O burst and so on.
  • Ultimately, the last CPU Burst ends with a system request to terminate execution.
  • The main concern is the CPU burst distribution.

CPU Scheduling

CPU Scheduler

When the CPU turn out to be idle then the operating system must select one of the process in the ready queue to be executed. Short term scheduler is user for selection process. There are different kind of algorithms that are used for ready queue such as FIFO, LIFO priority queue and so on. Generally, PCB is used to keep the record of queues.

There are mainly two types of scheduling

  • Preemptive scheduling
  • Non-preemptive scheduling

Preemptive Scheduling

There are main four circumstances in which CPU scheduling decision may take place:

  1. Whenever process switches from the running state to the wait state (as a result of I/O request or wait for termination of one of the child processes)
  2. Whenever a process switches form running state to ready state (i.e. when an interrupt occurs)
  3. Whenever a process switches form the waiting state to ready state (i.e. for I/O completion)
  4. When process terminates.

NOTE: for case 1 and 4 there is no choice in terms of scheduling, a new process must be selected for execution. In case 2,3 there is a choice.

Non-preemptive Scheduling

  • The scheduling which take places in case 1,4 then the scheduling is called as non-preemptive scheduling or cooperative.
  • In case of non-preemptive scheduling once the CPU has been allocated to a process and the process preserves CPU until it releases the CPU either by terminating or by switching to the waiting state.

Dispatcher

It is basically a module which offers control of the CPU to the process selected by short term scheduler. This function includes the following activities:

  1. Switching context
  2. Switching to the user mode
  3. In the user program jumping to the proper location to restart that program.

Dispatcher invoked during every process switch so it should be as fast as possible. The time taken by dispatcher to stop one process and start another process running is called as dispatcher latency.

Process Life Cycle

admin

We are a team of writers, researchers, and editors who are passionate about helping others live their best lives. We believe that life is a beautiful gift. We try to live our lives to the fullest and enjoy every moment. We are always learning and growing, and we cherish the relationships we have with our family and friends.

Leave a Reply