程序代写 OS-202 midterm 2020-21 Fall(v1) Page 1

OS-202 midterm 2020-21 Fall(v1) Page 1
Please enter your answers directly in nyu classes as if this was a homework or lab. The first two problems ask you to draw diagrams. As discussed in class, draw them with pencil and paper, take a picture, convert the picture to a pdf, and attach it as you would attach a pdf for a homework. Good Luck!
1 (10 points). Consider a system with two processes and three resource types, A, B, and C. The system has 3 units of A, 1 unit of B, and 5 units of C. Draw a resource allocation graph for this system that represents a state that is NOT deadlocked and NOT safe.
2 (10 points). Draw the process state diagram given in the notes. This diagram contains nodes (circles) showing process states and arcs (arrows) showing the possible state transitions. Remember to label the nodes and arcs.

Copyright By PowCoder代写 加微信 powcoder

3 (10 points). Define, but do NOT solve, the producer-consumer problem.
4 (15 points). The processes in the table on the right are run with a round robin scheduler having a quantum q = 10ms (all times are in milliseconds). A starts at t = 0ms and requires 18ms of CPU time to complete.
B starts at 4ms and requires 12ms. C starts at 8ms and requires 14ms.
A never blocks.
After B runs for 8ms, it blocks for 5ms and never blocks again. After C runs for 10ms, it blocks for 1ms and never blocks again.
A 0 18 never B 4 12 8 5 C 8 14 10 1
Start time
Blocks after for
At what time does each process finish? Show your work and use our standard tie-breaking rule if ties occur.
5 (10 points). The program below consists of two tasks that share a common variable X. Before execution begins, X is initialized to 50. The author included the (binary) semaphore S to force each line of each task to be atomic. Unfortunately, the program still would sometimes print different answers.
What are all the possible printouts that can occur? That is, assume the program is run many times. Each run will print two lines, but the two lines will not always be the same from run to run. List all the possibilities, making clear for each possibility which line is printed first.
Task #1 |
P(S); X = X*10; V(S); |
P(S); Print ¡®¡®Task 1:¡¯¡¯, X; V(S); |
P(S); X=X-3; V(S)
P(S); Print ¡®¡®Task 2:¡¯¡¯, X; V(S);
6 (35 points). Fill in the blanks with the appropriate technical term or phrase.
i. When the OS moves a process from the running state to ready, a
ii. The diagram used to model deadlock that contains squares, circles, and arrows is called a
iii. A program in execution is called a .
iv. A hardware instruction that makes solving the critical section problem easy is
v. The coordination problem where some processes just query a datebase while other processes modify the database is called
vi. The Banker¡¯s algorithm ensures that all processes remain in a state.
vii. A disadvantage of the ¡°shortage job first¡± process scheduling algorithm is the possibility of
7 (10 points). Consider a system containing 8 units of resource R and 20 units of resource S managed by the banker¡¯s algorithm. There are three processes X, Y, and Z. X¡¯s claim is 6 units of R and 4 units of S, written (6,4). Y¡¯s claim is (4,16). Z¡¯s claim is (8,16). Currently X has 2 unit of R and 4 units of S, written (2,4). Y has (0,0). Z has (0,8). There are no outstanding requests.
i What is the maximum number of units of R that X can request at this point that the banker will grant?
ii If Y instead of X makes a request for R, what is the maximum number of units that the banker will grant?
iii If Z instead of X or Y makes a request for R, what is the maximum number of units that the banker will grant? Justify your answers.
has occurred.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com