Computer Science 422/622 Test 1 - Mar 5 1990 Name________________________ 1. Answer the following T or F. ___ a. The number of processes in the "Ready to Run" state can never exceed the number of processors in the computer system. ___ b. A process that did a tremendous amount of computation and very little I/O would typically spend more time in the "Blocked" state than one which did a large amount of I/O and a small amount of computation. ___ c. A process could never enter the "Ready" state more times than it entered the "Blocked" state. 2. Describe exactly how the following attempts at a solution to the mutual exclusion problem satisfies or fails to satisfy the objectives of being safe, deadlock free, and starvation free. a. Process 1 Process 2 p1intending = TRUE; p2intending = TRUE; while (p2intending == TRUE); while (p1intending == TRUE); -- critical section --- -- critical section --- p1intending = FALSE; p2intending = FALSE; b. Process 1 Process 2 RETRY: RETRY: p1intending = TRUE; p2intending = TRUE; if (p2intending == TRUE) if (p1intending == TRUE) { p1intending = FALSE; { p2intending = FALSE; goto RETRY; } goto RETRY; } c. Process 1 Process 2 while (p2intending == TRUE); while (p1intending == TRUE); p1intending = TRUE; p2intending = TRUE; -- critical section --- -- critical section --- p1intending = FALSE; p2intending = FALSE; 3. Provide a functional (end user's) view of the Signal operation on a semaphore. (This question is NOT asking for an implementation). Signal(sem1): 4. The implementation of wait and signal used both disabling of interrupts and a Test and Set operation on a semaphore lock. a. Precisely why was interrupt disabling needed in the multiprocessor case? b. Could the Test and Set statements be safely commented out in a single processor environment. Explain why or why not. c. The operations began by disabling interrupts and obtaining the semaphore lock. In what order were these two operations carried out. d. Is the order in which interrupts are enabled and the lock released at the end critical? If so, in what order should they occur? 5. a. What does the value of the counting semaphore WAITED on by the producer in the bounded buffer producer consumer problem represent. b. Under precisely what conditions is a mutex semaphore required in a producer consumer problem?? c. Show EXACTLY how a producer/consumer solution could deadlock if the waits on the counting semaphore and the mutex semaphore were in the correct order in the consumer but the wrong order in the producer. 6. a. Suppose an application process goes into an infinite loop in a multitasking system. Precisely how does the OS regain control in order to preempt the process. b. When such a process is preempted, is its PCB placed in the blocked or Ready to Run list? c. Is a process typically scheduled more often by the dispatch or swap scheduler. 7. a. What is the main advantage of the use of pass by reference over copying in a message passing system.. b. Consider the producer/consumer problem in a message passing system. Compare the difficulty of the use of direct and mailbox naming in for both a single producer and consumer and multiple producers and consumers. Single producer/consumer - Multiple producers/consumers - c. Describe how a message passing system with mailbox naming can be used to simulate the effects of a counting semaphore.