In: Computer Science
Assume there are three processes A, B and C. All processes are submitted for execution at the same time. The process A executes for 2 milliseconds and then does I/O for 3 milliseconds and then executes for 3 milliseconds more. The process B executes for 4 milliseconds and then does I/O for 7 milliseconds. The process C executes for 2 millisecond and then does I/O for 4 milliseconds. Assume no contention for the resources and the order of execution (priority) is A, B and C.
Calculate the processor utilization with multiprogramming.
Step 1: Given that, there are three processes A, B, C.
Process A executes for 2ms and then does I/O for 3ms then executes for 3ms.
Process B executes for 4ms and then does I/O for 7ms.
Process C executes for 2ms and then does I/O for 4ms.
Priority for execution is A,B,C.
Step 2: In a multiprogramming environment, when a process is in I/O, the OS will schedule another process to CPU for execution. Lets see the time line of the three processes in a multiprogramming environment:
Process/timeline | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Process A | ||||||||||||||||||||
Process B | ||||||||||||||||||||
Process C |
The red color cells indicate process execution and the yellow cells indicate I/O.
Step 3: CPU Utilization = Time spent by CPU for execution / (Time spent by CPU for execution + CPU Idle time)
Here CPU idle time includes the time in which processes are only in I/O.
Time spent by CPU for execution = (2+3)+4+2 = 11ms
CPU Idle time = 9ms
Step 4: CPU Utilization = 11 / (11+9) = 0.55
Hence processor utilization with multiprogramming is 55%.