Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言操作系统代写 | COIS 3320H Winter 2021 Assignment 2

C语言操作系统代写 | COIS 3320H Winter 2021 Assignment 2


COIS 3320H
Winter 2021 Assignment 2
Due Date: 12th of March by 11:59PM

1- Based on Exercise 3.2.1 – Scheduling using FIFO, SJF, and SRT (6 Points)

For the 5 processes described below draw a timing diagram showing when each process will execute under FIFO, SJF, and SRT.
Determine the ATT (Average Turnaround Time) for each scheduling algorithm for the 5 processes described below.

P1 P2 P3 0 2 4 3 6 4

P4 P5 6 8 5 2

2- Based on Exercise 3.2.3 – Predicting CPU Bursts (2 points)

The following sequence of CPU bursts has been observed: 7, 5, 6, 15, 15, 15.

  1. a-  Using 7 as the initial estimate, S0, generate the sequence of predictions, Si, for the corresponding observed values Ti, where 1 <= i <=5 and α = 0.8.
  2. b-  Repeat the same predictions for α = 0.5.
  1. 3-  Based on Exercise 3.3.1 – Turnaround Time Under Round Robin Scheduling (2 points)

    Three processes, p1, p2, p3, arrive at the same time and start executing using RR scheduling.

    p1 starts first, followed by p2, and then p3.

    The respective total CPU times of the 3 processes are 8, 3, 5 time units.

    The context switching time is negligible.

    1. a-  Determine the average turnaround time, ATT, when the quantum is Q = 1 time unit.
    2. b-  Determine the average turnaround time, ATT, when the quantum is Q = 3 time units.
  2. 4-  Based on Exercise 3.3.2 – Determining Process Execution Time (5 points)

    n processes are time-sharing the CPU using RR scheduling, each requiring T ms of CPU time to complete.

    1. a-  How long will the execution take on a machine with n CPUs?
    2. b-  How long will the execution take on a single CPU machine when the context switch

      overhead is zero?

    3. c-  How long will the execution take on a single CPU machine when:
      1. The length of the time quantum is Q ms
      2. The length of the time quantum is Q ms
    4. d-  Repeat the previous calculation using n=5, T=10,000, Q=100, S=10.

5- Based on Exercise 3.3.5 – Scheduling with MLF (2 points)

A MLF algorithm uses 5 priority levels. At level 5, a process executes for Q = 1 ms. At each of the lower levels the quantum is doubled (2Q, 4Q, 8Q, 16Q).

The following processes are to be scheduled:

Process Arrival Total CPU Time P1 0 1
P2 1 3
P3 1 14

After termination, process p1 blocks for 4 ms and then reenters the queue again at level 5. Similarly, process p2 blocks for 5 ms and then reenters the queue again at level 5.

  1. a-  Draw a timing diagram for the first 33 ms. On each of the 3 lines (one per process) show when the process is running and at which priority level.
  2. b-  Determine the ATT for each process.

6- Based on Exercise 3.4.2 – Determining Feasible Schedules (4 points)

Three periodic processes with the following characteristics are to be scheduled (D is the period and T is the total CPU time):

Case 1 DT P1 50 3 P2 1000 70 P3 40 5

Case 2 P1

Case 3 P1

D T 50 15 10 5 4 1

D T 20 5 10 7 100 4

  1. a-  For each case, determine if a feasible schedule is likely to be generated by:
    1. RM
    2. EDF
  2. b-  Draw a timing diagram for the first 25 time units. For each of the 3 cases, show the

    schedules produced by RM and by EDF.

7- Based on Exercise 4.2.1 – Using P and V Operations to Enforce Precedence of Execution (2 points)

Four processes are executing the computations A through H:

The computations must be executed in the order given by the following precedence graph.

  1. a-  Insert P and V operations into the code to enforce the prescribed order. For example, since E and H must wait for A to complete, the processes p2 and p4 must each start with a P operation and A must end with 2 corresponding V operations.
  2. b-  What are the initial semaphore values?

8- Based on Exercise 4.3.2 – A Different Implementation of P and V (2 points)

The following implementation of P and V uses busy-waiting inside P. Rather than blocking the process when s is less or equal 0, the process is prevented from continuing by executing Pb(ds), where ds is a binary semaphore initialized to 0. A V(s) then unblocks a process by performing Vb on the binary semaphore ds.

a- Since the original solution also uses Pb and Vb (implemented using busy-waiting), why is the above solution much worse in terms of performance?

9- Based on Exercise 4.5.6 – An Inadequate Solution to the Dining Philosophers Problem (2 points)

Each of the five philosophers, p[i], in the dining philosophers problem executes the code:

a- Does the solution satisfy all requirements of the dining philosophers’ problem?