Unit 2-Part2
Unit 2-Part2
! Dispatch latency – time it takes for the dispatcher to stop one process and start another
running
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
! FCFS algorithm is non-preemptive in nature, that is, once CPU time has been allocated to a process,
other processes can get CPU time only after the current process has finished.
! This property of FCFS scheduling leads to the situation called Convoy Effect.
! To avoid Convoy Effect, preemptive scheduling algorithms like Round Robin Scheduling can be used
! as the smaller processes don’t have to wait much for CPU time
4 making their execution faster and leading to less resources sitting idle
! Associate with each process the length of its next CPU burst
! Use these lengths to schedule the process with the shortest time
! SJF is optimal – gives minimum average waiting time for a given set of processes
! The difficulty is knowing the length of the next CPU request
! Could ask the user
! Two schemes:
! Non-preemptive
! Preemptive – Also known as the Shortest-Remaining-Time-First (SRTF).
! Non-preemptive SJF is optimal if all the processes are ready simultaneously– gives
minimum average waiting time for a given set of processes.
! SRTF is optimal if the processes may arrive at different times
P1
0 3 7
! At time 0, P1 is the only process, so it gets the CPU and runs to completion
P1 P3 P2 P4
0 3 7 8 12 16
" P3 gets the CPU first since it is the shortest. P2 then P4 get the CPU in turn (based on arrival
time)
" Avg waiting time = (0+6+3+7)/4 = 4
P4 P1 P3 P2
0 3 9 16 24
12
τi 10
ti 6
time
" Since both a and (1 - a) are less than or equal to 1, each successive term has less weight than
its predecessor
P1 P2 P4 P1 P3
0 1 5 10 17 26
Gantt-Chart P1 P3 P2
0 7 11 16
time
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
! Typically, higher average turn around than SJF, but better response
! q should be large compared to context switch time
! q usually 10ms to 100ms, context switch < 10 usec
Gantt-Chart P1 P2 P1 P3 P2
0 4 8 11 15 16
Disadvantages
• It can't be implemented practically.
• This is because the burst time of all the processes can not be known in advance.
Multicore Processors
§ Recent trend to place multiple processor cores on same physical chip
§ Faster and consumes less power
§ Multiple threads per core also growing
§ Takes advantage of memory stall to make progress on another thread while memory retrieve
happens