Operating Systems 173323 (3 cu)

Exercise 4

CPU scheduling

  1. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds.

         Process    Burst time
         -------    ----------
            P1          10
            P2           1
            P3           2
            P4           1
            P5           5
    

    The processes are assumed to have arrived in the order P1,P2,P3,P4,P5, all at time 0.

    Draw two Gantt charts illustrating the execution of these processes using FCFS and a nonpreemptive SJF scheduling.

    Calculate waiting times and turnaround times for each process, and the average waiting times and average turnaround times for both schedulings.

  2. Consider the following set of processes, with the arrival times and the length of the CPU-burst time given in milliseconds.

         Process    Arrival time   Burst time
         -------    ------------   ----------
            P1          0              10
            P2          2               1
            P3          3               2
            P4          4               1
            P5          6               5
    

    Draw two Gantt charts illustrating the execution of these processes using nonpreemptive SJF and preemptive SJF scheduling.

    Calculate waiting times and turnaround times for each process, and the average waiting times and average turnaround times for both schedulings. Remember to substract the arrival times of the processes in waiting time and turnaround time calculations.

  3. Consider the following set of processes, with the the length of the CPU-burst time given in milliseconds and the priorities given so that smaller priority number means a higher priority.

         Process    Burst time     Priority
         -------    ----------     --------
            P1          10            3
            P2           1            1
            P3           2            3
            P4           1            4
            P5           5            2
    

    The processes are assumed to have arrived in the order P1,P2,P3,P4,P5, all at time 0.

    Draw a Gantt chart illustrating the execution of these processes using a priority scheduling. (Use FCFS for equal priority processes)

    Calculate waiting times and turnaround times for each process, and the average waiting time and average turnaround time for this scheduling.

  4. Consider the following set of processes, with the arrival times and the length of the CPU-burst time given in milliseconds.
         Process    Arrival time   Burst time
         -------    ------------   ----------
            P1         0.0             8
            P2         0.4             4
            P3         1.0             1
    
    Draw two Gantt charts illustrating the execution of these processes using FCFS and a nonpreemptive SJF scheduling.

    Calculate waiting times and turnaround times for each process, and the average waiting times and average turnaround times for both schedulings.

  5. What happens in the previous task (task number 4) if the CPU is forced to be idle for 1 ms at the beginning (from 0 ms to 1 ms) and then a nonpreemptive SJF is used ?

    Draw a Gantt chart for scheduling.

    Calculate waiting times and turnaround times for each process, and the average waiting time and average turnaround time for this scheduling.