KEMBAR78
SCHEDULING ALGORITHMS | PPTX
SCHEDULING
ALGORITHMS
PREPARED BY : DHAVAL SAKHIYA(13CSE533)
PRAKASH ASADIYA(13CSE501)
What is scheduling?
 One CPU with a number of processes. Only one process
can use the CPU at a time which process is going to be
execute that thing decide a by scheduler and it’s whole
thing is called scheduling.
Two types of scheduling:
1. Preemptive
2.Non- Preemptive
Preemptive :
i. In preemptive scheduling, the currently running process may be
interrupted and move to the ready state by OS(forcefully).
ii. It selects a process and lets it run for a specific time duration,
called time quantum.
iii. If process is still running at the end of the time interval, it is
suspended and the scheduler selects another process to run.
Non-Preemptive :
i. In non-preemptive scheduling, the running process can only
lose the processor voluntarily by terminating or by requesting
and I/O. OR, once CPU given to a process it can not be
preempted until the process completes its CPU burst.
ii. It selects a process to run and then just lets it run until it
blocks or terminates.
Types of scheduler
 Long-term scheduler:
 load a job in memory
 Runs infrequently
 Medium-term scheduler:
 Select ready process to run on CPU
 Should be fast
 Short-term scheduler:
 Reduce multiprogramming or memory consumption
Process Scheduling
• “process” and “thread” used interchangeably
• Which process to run next
• Many processes in “ready” state
New Ready Running Exit
Waiting
FORMULA :
 TURN AROUND TIME:
 TAT=(Waiting Time)(W.T) + (Burst Time)(B.T)
 OR
 = (Completion Time)(C.T) – (Arrival Time)(AT)
 WAITING TIME:
 WT=(Turn Around Time)(TAT) – (Burst Time)(B.T)
 OR
 =(Completion Time)(C.T) – (Arrival Time)(A.T) – (Burst Time)(B.T)
First-Come First-Serve (FCFS)
 One ready queue;
 OS runs the process at head of the queue;
 New processes come in at the end of the queue;
 Running process does not give up the CPU until it terminates
or it performs IO.
Shortest Job First (SJF)
 Best approach to minimize waiting time.
 Impossible to implement.
 Processer should know in advance how much time process will take.
 SJF is optimal – gives minimum average waiting time for a given set of processes.
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
 SJF (non-preemptive):
0 7 8 12 16
P1 P2 P3 P2 P4 P1
Example of Preemptive SJF
Process Arrival Time Burst Time
P1 0 7
P2 2 4
P3 4 1
P4 5 4
SJF (preemptive)
0 2 4 5 7 11 16
Round Robin Scheduling
 Each process is provided a fix time to execute called quantum.
 Once a process is executed for given time period. Process is preempted and
other process executes for given time period.
 Context switching is used to save states of preempted processes.
Priority Based Scheduling
 Each process is assigned a priority. Process with highest priority is to be executed first and so on.
 Processes with same priority are executed on first come first serve basis.
 Priority can be decided based on memory requirements, time requirements or any other
resource requirement.
Priority based non pre-preemptive Algo Example
0
P4 P2 P1 P3
6 9 14 17
SCHEDULING ALGORITHMS

SCHEDULING ALGORITHMS

  • 1.
    SCHEDULING ALGORITHMS PREPARED BY :DHAVAL SAKHIYA(13CSE533) PRAKASH ASADIYA(13CSE501)
  • 2.
    What is scheduling? One CPU with a number of processes. Only one process can use the CPU at a time which process is going to be execute that thing decide a by scheduler and it’s whole thing is called scheduling. Two types of scheduling: 1. Preemptive 2.Non- Preemptive
  • 3.
    Preemptive : i. Inpreemptive scheduling, the currently running process may be interrupted and move to the ready state by OS(forcefully). ii. It selects a process and lets it run for a specific time duration, called time quantum. iii. If process is still running at the end of the time interval, it is suspended and the scheduler selects another process to run.
  • 4.
    Non-Preemptive : i. Innon-preemptive scheduling, the running process can only lose the processor voluntarily by terminating or by requesting and I/O. OR, once CPU given to a process it can not be preempted until the process completes its CPU burst. ii. It selects a process to run and then just lets it run until it blocks or terminates.
  • 5.
    Types of scheduler Long-term scheduler:  load a job in memory  Runs infrequently  Medium-term scheduler:  Select ready process to run on CPU  Should be fast  Short-term scheduler:  Reduce multiprogramming or memory consumption
  • 6.
    Process Scheduling • “process”and “thread” used interchangeably • Which process to run next • Many processes in “ready” state New Ready Running Exit Waiting
  • 7.
    FORMULA :  TURNAROUND TIME:  TAT=(Waiting Time)(W.T) + (Burst Time)(B.T)  OR  = (Completion Time)(C.T) – (Arrival Time)(AT)  WAITING TIME:  WT=(Turn Around Time)(TAT) – (Burst Time)(B.T)  OR  =(Completion Time)(C.T) – (Arrival Time)(A.T) – (Burst Time)(B.T)
  • 8.
    First-Come First-Serve (FCFS) One ready queue;  OS runs the process at head of the queue;  New processes come in at the end of the queue;  Running process does not give up the CPU until it terminates or it performs IO.
  • 10.
    Shortest Job First(SJF)  Best approach to minimize waiting time.  Impossible to implement.  Processer should know in advance how much time process will take.
  • 11.
     SJF isoptimal – gives minimum average waiting time for a given set of processes. Process Arrival Time Burst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4  SJF (non-preemptive): 0 7 8 12 16
  • 12.
    P1 P2 P3P2 P4 P1 Example of Preemptive SJF Process Arrival Time Burst Time P1 0 7 P2 2 4 P3 4 1 P4 5 4 SJF (preemptive) 0 2 4 5 7 11 16
  • 13.
    Round Robin Scheduling Each process is provided a fix time to execute called quantum.  Once a process is executed for given time period. Process is preempted and other process executes for given time period.  Context switching is used to save states of preempted processes.
  • 15.
    Priority Based Scheduling Each process is assigned a priority. Process with highest priority is to be executed first and so on.  Processes with same priority are executed on first come first serve basis.  Priority can be decided based on memory requirements, time requirements or any other resource requirement.
  • 16.
    Priority based nonpre-preemptive Algo Example 0 P4 P2 P1 P3 6 9 14 17