Learning Goal: I’m working on a c programming multi-part question and need an ex

Learning Goal: I’m working on a c programming multi-part question and need an explanation and answer to help me learn.
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
M5
P8
M3, M4
M2
P9
M5, M6
M6
In addition, you are given the following precedence relation:
⇒= { (1,2) (1,3) (1,8) (1,9) (2,8) (2,9) (3,4) (3,8) (3,9) (4,5) (5,7) (5,9) }
(20pts) Construct the Precedence Graph (not containing any redundant or transitive edges)
(20pts) Determine if the system above is always determinate. If it is not, indicate which precedence relations are missing.
(30 pts) In the first problem, there were 9 processes, many of which were listed as pairs under the precedence relation. Suppose we are dealing with a system of only 5 processes named P1 through P5. You are given a set of constraints that are expressed by the following precedence relation:
⇒ = { (P1,P3), (P1, P5), (P2,P4), (P3, P4), (P4, P5) }
Provide pseudocode to show how you can use semaphores to enforce these constraints (i.e., the precedence relation ⇒).
4. (30pts) Implement a system of three processes (in C) which read and write sequence numbers to a file. Each of the three processes P1, P2, and P3 must obtain 50 integers from the file. The file only holds one integer at any given time. (This means that you will can only get one number at a time, and therefore must run the following steps in a loop. 50 times per process). Given a file, F, containing a single integer, each process must perform the following steps 50 times:
Open F
Read the integer N from the file
Close F
Output N and the process’ PID (either on screen or test file)
Increment N by 1
Open F
Write N to F (overwriting the current value in F)
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)?
Rewrite your implementation of these 3 processes to guarantee that no duplicate numbers are ever obtained by the processes. In other words, each time the file is read by any process, that process reads a distinct integer.
Briefly describe why the code sequence above can lead to duplication of integer values and discuss how your solution will avoid these duplicates.
Your answer to this question should include:
* The source to your programs (as an attachment)
* A sample of the output demonstrating your program (In a PDF along with your other answers)
NOTE: Programs must compile and execute on the CSE machines. It is imperative that the file F containing in the integer is located on the local disk. On Linux, the /tmp directory is located on the local file system.

Leave a Reply

Your email address will not be published. Required fields are marked *