24.4k views
2 votes
Consider three processes P1, P2, and P3, all ready to run at time = 0. Each process has two CPU bursts, separated by a single I/O burst. When its first CPU burst is completed, each process requests a blocking I/O operation on an I/O device. It becomes ready for the second CPU burst only when its I/O burst completes.

The CPU scheduling policy is non-preemptive Shortest-Job-First (SJF). The system has only one CPU.
The lengths of the CPU bursts of the processes are given below:
P₁: 2 ms (each CPU burst)
P2: 4 ms (each CPU burst)
P3: 5 ms (each CPU burst)
When a process starts receiving service for I/O, its I/O burst takes 10 ms.

Give the average turnaround time for these processes, assuming each process P₁ performs I/O on a separate I/O device D₁ Show your work (including Gantt charts for the CPU and all I/O devices). Assume FCFS scheduling on all I/O devices.

1 Answer

3 votes

Final answer:

The average turnaround time for processes P1, P2, and P3 scheduled using non-preemptive SJF CPU scheduling is approximately 17.33 milliseconds. This was calculated using their respective CPU and I/O burst times under the assumption that each process immediately performs I/O on a separate device after its first CPU burst.

Step-by-step explanation:

The question is about calculating the average turnaround time for three processes P1, P2, and P3 under a non-preemptive Shortest-Job-First (SJF) CPU scheduling policy with separate I/O devices for each process. Since all processes are ready at time = 0 and the system uses SJF scheduling, P1 will run first as it has the shortest CPU burst of 2 ms.

Gantt Chart for CPU:

  • Time 0-2ms: P1's first CPU burst
  • Time 2-6ms: P2's first CPU burst
  • Time 6-11ms: P3's first CPU burst
  • Time 12-14ms: P1's second CPU burst (after 10 ms I/O)
  • Time 14-18ms: P2's second CPU burst (after 10 ms I/O)
  • Time 18-23ms: P3's second CPU burst (after 10 ms I/O)

Assuming each process performs I/O on a separate I/O device immediately after its first CPU burst, the process turnaround times are as follows:

  • P1 Turnaround Time: 2ms (1st CPU) + 10ms (I/O) + 2ms (2nd CPU) = 14ms
  • P2 Turnaround Time: 4ms (1st CPU) + 10ms (I/O) + 4ms (2nd CPU) = 18ms
  • P3 Turnaround Time: 5ms (1st CPU) + 10ms (I/O) + 5ms (2nd CPU) = 20ms

To find the average turnaround time, we add the turnaround times of all processes and divide by the number of processes: (14ms + 18ms + 20ms) / 3 = 52ms / 3 ≈ 17.33ms

Thus, the average turnaround time for the processes is approximately 17.33 milliseconds.

User Tom Anthony
by
8.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.