Operating system problems

shashankreddy
homeworkfall.docx

1. Consider a system of 9 processes, P = {p1, …, p9} Associated with the system are 6 memory cells, M = {M1, .., M6}

The domain and range for each process is given in the following table:

Process pi

Domain D(pi)

Range R(pi)

p1

M1, M2

M3

p2

M1

M5

p3

M3, M4

M1

p4

M3, M4

M5

p5

M3

M4

p6

M4

M4

p7

M5

M6

p8

M3, M4

M2

p9

M5, M6

M6

In addition, you are given the following precedence relation:

 = {(1,2),(1,6),(2,3),(2,4),(2,5),(3,6),(3,8),(4,6),(4,7),(5,7),(5,8),(6,8),(6,9),(7,9),(8,9)}

a. Construct the Precedence Graph (not containing any redundant or transitive edges)

b. Determine if the system above is always determinate. If it is not, add to  necessary elements to make it determinate.

2. Suppose we are dealing with a system of 5 processes with a set of constraints that are expressed by the following precedence relation: :{(P1,P3), (P1, P5), (P2,P4), (P3, P4), (P4, P5)}

As a programmer, show how you can use semaphores to enforce these constraints (i.e., the precedence relation ).

3. Write a simple sequence-number system in C through which three concurrent processes, P1, P2, and P3, each obtaining 200 unique integers. Use the fork() call to create P, P2, and P3. Given a file, F, containing a single number, each process must perform the following steps:

1. Open F

2. Read the sequence number N from the file

3. Close F

4. Output N and the process' PID (either on screen or test file)

5. Increment N by 1

6. Open F

7. Write N to F

8. Close F.

Will the numbers that are read by the processes P1, P2, and P3 be always unique or do you observe duplicates of numbers being obtained by different processes (i,e, does a particular integer x appear in the output of more than on process)? What the final number in the file will be? Rewrite the above program so as to guarantee that no duplicate number are ever obtained by the processes. Briefly describe why the code sequence above can lead duplication of sequence numbers and discuss how your solution will avoid duplicates.