• In computer science, scheduling is the method
by which threads, processes or data flows are
given access to system resources
• Long-term scheduling
• Medium-term scheduling
• Short-term scheduling
• CPU utilization
• Throughput
• Turnaround time
• Waiting time
• Response time
• is the simplest scheduling algorithm, FIFO
simply queues processes in the order that
they arrive in the ready queue.
• The FCFS scheduling algorithm is non
preemptive. Once the CPU has been allocated
to a process, that process keeps the CPU until
it releases the CPU.
Process Burst Time
P1 24
P2 3
P3 3
• Suppose that the processes arrive in the order: P1
, P2 , P3
The Gantt Chart for the schedule is:
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
P1 P2 P3
24 27 300
P1 P2 P3
• Associate with each process the length of its next
CPU burst. When the CPU is available, it is assigned
to the process that has the smallest next CPU burst.
– Non-preemptive – once CPU given to the process
it cannot be preempted until completes its CPU
burst
– preemptive – if a new process arrives with CPU
burst length less than remaining time of current
executing process, preempt. This scheme is know
as the
Shortest-Remaining-Time-First (SRTF)
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (non-preemptive)
• Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P3 P2
73 160
P4
8 12
P1 P3 P2 P4
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
• SJF (preemptive)
• Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P3P2
42 110
P4
5 7
P2 P1
16
P1 P3P2 P4 P1P2
• A priority number (integer) is associated with each process
• The CPU is allocated to the process with the highest priority (smallest
integer  highest priority)
– Preemptive
– non preemptive
• SJF is a priority scheduling where priority is the predicted next CPU burst
time
• Problem  Starvation – low priority processes may never execute
• Solution  Aging – as time progresses increase the priority of the
process
Process Burst Time Arrival Time Priority
P1 10 0 3
P2 1 0 1
P3 2 0 4
P4 1 0 5
P5 5 0 2
P3P5P2
61 190 16 18
P3P5P2
61 190 16 18
P4P1P2 P5 P1 P3 P4
• Each process gets a small unit of CPU time (time quantum),
usually 10-100 milliseconds. After this time has elapsed, the
process is preempted and added to the end of the ready queue.
• If there are n processes in the ready queue and the time
quantum is q, then each process gets 1/n of the CPU time in
chunks of at most q time units at once. No process waits more
than (n-1)q time units.
Process Burst Time Arrival
P1 24 0
P2 3 0
P3 3 0
• The Gantt chart is:
• Average waiting time: (0+4+7+(10-4))/3 = 5.66
With FCFS: (0+24+27)/3 = 17
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
P2 P3 P1 P1P1 P1P1P1
• FCFS (First-come, First-Served)
– Non-preemptive
• SJF (Shortest Job First)
– Can be either
– Choice when a new (shorter) job arrives
– Can preempt current job or not
• Priority
– Can be either
– Choice when a processes priority changes or when a higher priority
process arrives
Presentation by adeel

Presentation by adeel

  • 4.
    • In computerscience, scheduling is the method by which threads, processes or data flows are given access to system resources • Long-term scheduling • Medium-term scheduling • Short-term scheduling
  • 5.
    • CPU utilization •Throughput • Turnaround time • Waiting time • Response time
  • 6.
    • is thesimplest scheduling algorithm, FIFO simply queues processes in the order that they arrive in the ready queue. • The FCFS scheduling algorithm is non preemptive. Once the CPU has been allocated to a process, that process keeps the CPU until it releases the CPU.
  • 8.
    Process Burst Time P124 P2 3 P3 3 • Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: • Waiting time for P1 = 0; P2 = 24; P3 = 27 • Average waiting time: (0 + 24 + 27)/3 = 17 P1 P2 P3 24 27 300 P1 P2 P3
  • 9.
    • Associate witheach process the length of its next CPU burst. When the CPU is available, it is assigned to the process that has the smallest next CPU burst.
  • 10.
    – Non-preemptive –once CPU given to the process it cannot be preempted until completes its CPU burst – preemptive – if a new process arrives with CPU burst length less than remaining time of current executing process, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF)
  • 11.
    Process Arrival TimeBurst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (non-preemptive) • Average waiting time = (0 + 6 + 3 + 7)/4 = 4 P1 P3 P2 73 160 P4 8 12 P1 P3 P2 P4
  • 12.
    Process Arrival TimeBurst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (preemptive) • Average waiting time = (9 + 1 + 0 +2)/4 = 3 P1 P3P2 42 110 P4 5 7 P2 P1 16 P1 P3P2 P4 P1P2
  • 13.
    • A prioritynumber (integer) is associated with each process • The CPU is allocated to the process with the highest priority (smallest integer  highest priority) – Preemptive – non preemptive • SJF is a priority scheduling where priority is the predicted next CPU burst time • Problem  Starvation – low priority processes may never execute • Solution  Aging – as time progresses increase the priority of the process
  • 14.
    Process Burst TimeArrival Time Priority P1 10 0 3 P2 1 0 1 P3 2 0 4 P4 1 0 5 P5 5 0 2 P3P5P2 61 190 16 18 P3P5P2 61 190 16 18 P4P1P2 P5 P1 P3 P4
  • 15.
    • Each processgets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. • If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
  • 16.
    Process Burst TimeArrival P1 24 0 P2 3 0 P3 3 0 • The Gantt chart is: • Average waiting time: (0+4+7+(10-4))/3 = 5.66 With FCFS: (0+24+27)/3 = 17 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30 P2 P3 P1 P1P1 P1P1P1
  • 17.
    • FCFS (First-come,First-Served) – Non-preemptive • SJF (Shortest Job First) – Can be either – Choice when a new (shorter) job arrives – Can preempt current job or not • Priority – Can be either – Choice when a processes priority changes or when a higher priority process arrives