College of Computer & Information Sciences
Information Technology Department
IT 325: Operating Systems
Assignment 7 first Semester 1433/1434H – 2012/2013
Q1) The following is a set of three interacting processes that can access two shared semaphores: semaphore U = 2; semaphore V = 0; [Process 1] [Process 2] [Process 3] L1:wait(U) L2:wait(V) L3:wait(V) type("B") type("D") type("A") signal(V) type("C") goto L3 goto L1 signal(V) goto L2
Within each process the statements are executed sequentially, but statements from different processes can be interleaved in any order that's consistent with the constraints imposed by the semaphores. When answering the questions below assume that once execution begins, the processes will be allowed to run until all 3 processes are stuck in a wait() statement, at which point execution is halted. A. Assuming execution is eventually halted, how many A's are printed when this set of processes runs? B. Assuming execution is eventually halted, how many B's are printed when the set of processes runs? C. What is the smallest number of D's that might be printed when this set of processes runs?
D. Is BDCDCAABDCBDCA a possible output sequence when this set of processes runs? E. Is BDCDBACBDCAA a possible output sequence when this set of processes runs?
Yes: start: U=3 V=0 type C: U=2 V=1 type A: U=2 V=0 type B: U=2 V=1 type A: U=2 V=0 type C: U=1 V=1 type D: U=1 V=0 type B: U=1 V=1 type C: U=0 V=2 type A: U=0 V=1 type B: U=0 V=2 type D: U=0 V=1