Draw a Gantt chart using Shortest Job First SFJ Preemptive I
Draw a Gantt chart using Shortest Job First (SFJ) Preemptive:
In this question, I\'m confused because we are asked to draw SFJ that means shortest job will get executed first right?
but they include priority in the table, Are we supposed to ignore it? please help me solve the question with explanation if possible thank you
| process id | arrival time | priority | burst time |
| A | 0 | 5 | 20 |
| B | 4 | 1 | 12 |
| C | 12 | 2 | 16 |
| D | 16 | 4 | 4 |
| E | 20 | 3 | 8 |
Solution
This is Shortest Job First Scheduling. So consider Shortest job First and then the priority. There is no problem scheduling A,B and C as their shortest burst time and priorities are same in the order B,C and A.
The problem arises with D and E process as their burst time is small but priority is low. This is not priority scheduling.
GANTT Chart
| A | B | D | E | C | A |
0 4 16 20 28 44 60
Start with A as it arrives first
At Arrival Time 4 B arrives so B executes as it has Higher priority and lower burst time
After B , D executes from 16 for 2 ms as D arrives and D has smaller burst time than C So D executes for 4 ms and exits.
Now comes E , E has lower priority than C but burst time is lower so E executes and exit
Now we are left with A and C
C executes first as it has high priority
and last A executes.
