In: Computer Science
Consider the following set of jobs to be scheduled for execution on a single CPU system.
Job |
Arrival Time |
Burst (msec) |
Priority |
A |
0 |
6 |
3 (Silver) |
B |
1 |
2 |
1 (Diamond) |
C |
3 |
5 |
3 (Silver) |
D |
5 |
3 |
4 (Bronze) |
E |
7 |
2 |
2 (Gold) |
Gantt chart showing First-Come-First-Served (FCFS):
F.C.F.S is non preemptive Algorithm
F.C.F.S Algorithm allows the process whichever arrived earlier.Here A comes at 0 th time so it is scheduled first.By the time A completed Execution B,C,D are in Ready Queue. From B,C,D B is Arrived Early so B is Scheduled next.By the time B is Completed C,D,E are in Ready Queue. From C,D,E, C is Arrived Early so C is scheduled next.then D then E
Gantt chart showing preemptive PRIORITY scheduling:
Here 1(Diamond) has higher priority ,4(Bronze) has Lower Priority
According to Premptive Priority Scheduling we should allow processes to preempt from execution if a process with highest priority comes .
At Arrival time 0 A comes First and has priority 3 .and it executed for 1 time
At Arrival time 1 B comes with the priority higher than A so A should be preempted ,put into ready Queue and allow B should be Executed next.As B is the Highest Priority among all other processes so it should be executed until it's completion.
At Arrival time 3 there are A and C processes are in Ready Queue.As A and C have same priorities so we should take the processes which is having lowest Arrival time..so we should take A as next One to be Executed.Until 7th time we allow A to be Executed because at 7th time E new process is coming into Ready Queue with highest Priority(2)
At Arrival time 7 there are 3 processes are in Ready Queue they are C,D and E. we preempt A from Execution as E has highest priority and allow E to be Executed completely as E has Highest Priority among remaining processes in Ready Queue
At Arrival time 9 there are 3 processes are in Ready Queue they are A,C,D .As A and C have same priorities and D has lower priority than A and C we allow the process A as it is arrived earlier and has higher priority than D
At Arrival time 9 there are 3 processes are in Ready Queue they are C,D .C has Higher Priority than D.So C should be allowed to execute next then D.
Final Gantt chart for Preemptive Priority Scheduling:
Gantt Chart For Highest Response Ratio Next:
In this Algorithm we alllow the first process which was arrived earlier to be Executed Smoothly and from next process onwards we Calculate H.R.R.N .whichever process has highest H.R.R.N that is Scheduled first.
B's H.R.R.N is Highest so we allow B to Execution
C and D both have Highest H.R.R.N but we select C because it is arrived earlier than D.So we schedule C next
As E's H.R.R.N is highest we should E next then D
Final Gantt Chart for H.R.R.N:
Gantt Chart For Round Robin:
RoundRobin is Premptive version of F.C.F.S
Given Time Quantum=4
After every 4th time the process gets preempted.
at Arrival time 0 A will enter into Execution so it will execute upto 4 and then preempts
By time 4 B,C are in ready Queue and A is pushed into Queue After B and C. B is allowed to Execute completely as it wants 2 units of Execution. Then C is Executed for another 4 units and C is preempted
By the time 10 A,D,E and C are in Queue.Next A is Allowed to Execute remaining 2 units(2)
D,E AND C are in queue. so D should be allowed to execute next
Next E as it is in first in queue
Next C's remaining Units(1) are Executed
Final Gantt Chart For Round Robin