CPU Scheduling solutions

Below is a table of jobs that we must schedule on a batch operating system. All jobs are available from the start.

Job    Arrival time    Run time
 J1        0            5 seconds
 J2        0            6 seconds
 J3        0            1 second
 J4        0            2 seconds
  1. Create a time-line to illustrate the First-Come First-Served (FCFS) strategy. It should include the start/stop times of each job.

    Just run the jobs in the order given:

       J1         J2          J3  J4
     |----------|------------|--|----|-->
     0          5           11 12   14
  2. Compute the average turnaround time of the four jobs using your FCFS time-line from the previous question.

    Turnaround is completion minus arrival time.

      J1:  5 - 0 =  5
      J2: 11 - 0 = 11
      J3: 12 - 0 = 12
      J4: 14 - 0 = 14
    
      Sum is 5 + 11 + 12 + 14 = 42
      So average is 42 ÷ 4 = 10.5
  3. Create a time-line to illustrate the Shortest Job Next (SJN) strategy. It should include the start/stop times of each job.

      J3  J4   J1         J2
     |--|----|----------|------------|-->
     0  1    3          8           14
  4. Compute the average turnaround time of the four jobs using your SJN time-line from the previous question.

      J1:  8 - 0 =  8
      J2: 14 - 0 = 14
      J3:  1 - 0 =  1
      J4:  3 - 0 =  3
    
      Sum is 8 + 14 + 1 + 3 = 26
      So average is 26 ÷ 4 = 6.5