


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Quiz; Professor: Gupta; Class: System Programming; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2006;
Typology: Quizzes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Note: Completion of quiz is an individual effort. The quiz takes 10 minutes. The student gets additional 5 points for taking the quiz. Each question has ONLY ONE ANSWER!!!
1. (1 Point) Threads of the same task have the following characteristics: (I) Share the same address space, (II) Reduce context switching overhead; (III) Are protected from each other the same way as processes. Which thread characteristics are correct? a. I, II, III b. I, III **c. I, II
Note: Since the binding between user threads and OS threads of the multi-threads kernel was ambiguous (i.e., both threads of the process P could be bound to one or two OS threads), we accepted answer (a) as well as a correct anwer.
3. (1 Point) Priority inversion between two processes, one with high priority and the other with low priority, that share a critical section, will cause the following problem : a. high priority process executes before low priority process and finishes faster than it should b. low priority process executes before high priority process and finishes faster than it should c. high priority process waits for low priority process (that holds the semaphore) to finish, but the low priority process never gets scheduled d. low priority process changes priority temporary to the priority of the high priority process 4. (1 Point) What is the minimum number of parameters to a ‘ message send ’ operation? a. 1 b. 2 c. 3
5. (1 Point) Rendezvous message passing synchronization approach requires a. Double buffering b. No buffering c. A buffer queue d. A place to meet 6. (1 Point) Consider the 2-process solution to the critical section problem ( ‘i’ refers to the current process and ‘j’ is the other one):
repeat while turn <> i do no-op;
This solution does NOT satisfy a. Mutual Exclusion b. Progress c. Bounded Waiting d. Both (b) and (c) e. None of the above
Note: This is the strict alteration solution from Tanenbaum book, chapter 2.2. Bounded waiting is inherently satisfied in strict alteration solution because the code forces each process to be only once in critical region, and after that another process must access the critical region. Hence, each process waits only one cycle to get in the critical region. What is NOT satisfied is progress since one process could block in remainder section and the progress of the overall solution would be hindered. See Tanenbaum textbook and also class notes.
9. (2 Points) Complete the pseudo-code solution to the bounded buffer problem, assuming names Down()=P(), Up()=V() , and given:
binary semaphore m; semaphore f; /* counting semaphore/ semaphore d; / counting semaphore*/ m=1; f=n; d=0;
Producer(i): Loop: …………………/* (1) …………………/* (2) Deposit new data x into buffer V(m); …………………/* (3) EndLoop
Consumer(i): Loop: P(d); P(m); Consume next data y from buffer ………………/* (4) ………………/* (5) EndLoop
a. P(f)=>(1), P(m)=>(2), V(f)=>(3), V(m)=>(4), V(d)=>(5) b. P(f)=>(1), P(m)=>(2), V(d)=>(3), V(m)=>(4), V(f)=>(5) c. P(d)=>(1), P(m)=>(2), V(d)=>(3), V(m)=>(4), V(d)=>(5) d. P(d)=>(1), P(m)=>(2), V(f)=>(3), V(m)=>(4), V(d)=>(5)
Note: This is the producer/consumer problem with bounded buffer solved with counting semaphores (using m for mutex, f for empty and d for full semaphores in the Tanenbaum book, chapter 2.2) – see lecture notes, Tanenbaum textbook and R&R implementation