Question

In: Computer Science

11. Consider three processes P1, P2, and P3, and all them three are ready to run...

11. Consider three processes P1, P2, and P3, and all them three are ready to run at time = 0. Each process has two CPU bursts. When its first CPU burst is completed, each process requests a blocking I/O operation on a separate I/O device. When a process starts to receive service for I/O, the OS scheduler selects and dispatches another process available at the ready queue. The CPU scheduling policy is preemptive priority-based scheduling, where a process being running can be preempted at the arrival of a higher priority process (think about how a preemptive SJF preempts a job currently being running). A smaller priority value indicates a higher priority. Assume the system has only one CPU core.

Process          Priority           1st CPU burst             I/O burst         2nd CPU burst

P1                   1                      5                                  20                    5         

P2                   2                      5                                  10                    10

P3                   3                      5                                  4                      5

Draw the Gantt chart for the above system (make sure to highlight process preemption and completion); calculate the average turnaround time and average waiting time – show your work.

Solutions

Expert Solution

Preemptive Priority Scheduling:

In this algorithm, a process with highest priority will execute first for some fixed time. It is the pre-emptive algorithm.

  • The next highest priority process will execute only after completion of the execution of the before process for some fixed time. Let the timestamp is 5.

  • Here, a smaller priority number means higher execution priority. That is priority number 1 is the higher execution priority.

  • When its first CPU burst is completed, each process requests a blocking I/O operation on a separate I/O device.

  • When a process starts to receive service for I/O, the OS scheduler selects and dispatches another process available at the ready queue.

Gantt diagram for Preemptive Priority Scheduling:

Now, calculate the turnaround time to find the waiting time.

Turnaround time = Completion time – Arrival time

Waiting time = Turnaround time - Burst time

Total turnaround time = Sum of turnaround times of all processes

Total turnaround time = 30+35+39= 104

Average turnaround time = Sum of turnaround times of all processes/ number of process

Average turnaround time =104/3=34.67

Total waiting time = Sum of waiting times of all processes

Total waiting time = 20+20+29= 69.

Average waiting time = Sum of waiting times of all processes/ number of process

Average waiting time = 69/ 3 = 23

Therefore, using Preemptive Priority Scheduling, the average turnaround time is 34.67 and the average waiting time is 23.


Related Solutions

6.1) Consider 3 processes, P1, P2, and P3, all available at time 2, 0, 3, respectively,...
6.1) Consider 3 processes, P1, P2, and P3, all available at time 2, 0, 3, respectively, with the CPU bursts as 6, 9, and 4, respectively, what would be the turnaround time for each of the processes and what would be the average turnaround time for those 3 processes if SJF (Shortest Job First) CPU scheduling algorithm were used? (5 points) 6.2) Based on the same scenario given in the previous question, what would be the turnaround time for each...
Consider following four processes arriving in the order of P1, P2, P3 and P4. Process   Arrival...
Consider following four processes arriving in the order of P1, P2, P3 and P4. Process   Arrival Time CPU burst Time P1             0.0     6 P2    0.0                              8 P3              0.0                                7 P4              0.0                                 3 What is the average waiting time for RR scheduling (time quantum = 5)? What is the average waiting time for SJF scheduling? What is the average waiting time for FCFS scheduling?
Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a...
Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI of 1.0. P3 has a 4.0 GHz clock rate and has a CPI of 2.2. a. Find execution time for each processor for a program with 2 x 10 9 instructions. Which one is the fastest? b. If the processors each execute a program in...
Consider three different processors P1, P2, and P3, executing the same instruction set. P1 has a...
Consider three different processors P1, P2, and P3, executing the same instruction set. P1 has a clock cycle time of 300 picosecond and a CPI (clock cycles per instruction) of 1.5. P2 has a clock cycle time of 400 picosecond and a CPI of 1.0. P3 has a clock cycle time of 250 picosecond and a CPI of 2.0. P1 is running a program with 10 instructions. P2 is running a different program with 20 instructions. P3 is running a...
Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a...
Consider three different processors P1, P2, and P3 executing the same instruction set. P1 has a 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI of 1.0. P3 has a 4.0 GHz clock rate and has a CPI of 2.2. a. Which processor has the highest performance expressed in instructions per second? b. If the processors each execute a program in 10 seconds, find the number of cycles and the...
6. Consider the following set of processes P1, P2, P3, P4. Process Burst Time Arrival Time...
6. Consider the following set of processes P1, P2, P3, P4. Process Burst Time Arrival Time Priority P1 3 0 1 P2 5 1 2 P3 8 3 3 P4 4 4 2 a) Draw Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: first-come, first-served (FCFS), priority scheduling (larger number=high priority), and Round-Bobin (RR, quantum=2). b) Compute the average waiting time, turnaround time for the three algorithms. Turnaround time – amount of time to...
1.) You are given 4 processes P1,P2, P3, P4 all ariving at the same time t=0,...
1.) You are given 4 processes P1,P2, P3, P4 all ariving at the same time t=0, in a dual-processor SMP. (The two CPUs are referred to as CPU-0 and CPU-1.) The service time for each process is 40s, 20s, 20s and 10s respectively (a) What are the possibilities for the turnaround time of the job that includes the execution of all 4 processes? You may assume that each service time is just CPU time and no process interferes with the...
Consider three different processors P1, P2 and P3 executing the same instruction set with clock rates...
Consider three different processors P1, P2 and P3 executing the same instruction set with clock rates and CPI given in the following table: Processor Clock Rate CPI P1 2 GHz 1.5 P2 1.5 GHz 1.0 P3 3 GHz 2.5 c) We are trying to reduce the execution time by 30% but this leads an increase of 20% in the CPI. What clock rate should we have to get this time reduction? b) If the processors each execute a program in...
Suppose that there are three different populations we want to compare, say P1, P2, and P3....
Suppose that there are three different populations we want to compare, say P1, P2, and P3. Each of these populations is normal. A random sample from each population is taken, and the results are given below. P1 P2 P3 10 6 5 12 8 9 9 3 12 15 0 8 13 2 4 a) Find the sample means and sample variance for each sample. Use Statistical Software and record the results in your Word document. b) Combine all samples...
Suppose that there are three different populations we want to compare, say P1, P2 and P3....
Suppose that there are three different populations we want to compare, say P1, P2 and P3. Each of these populations are normal. A random sample from each population is taken and the results are given below. P1 P2 P3 10 6 5 12 8 9 9 3 12 15 0 8 13 2 4 a) Find the sample means and sample variance for each sample. Use Excel and record the results in your Word document. b) Combine all samples and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT