Spring 2001, CSE 428: Quiz 7.3 - 15 March 2001


Please write your Name and Student ID,at the top of the page.
By default, this quiz will be returned in Section 1 (afternoon section).
  1. [Pts 4]  Assume that a thread T is executing a synchronized method m() on an object x of class C, and hence T is holding a lock L. For each of the following cases, say whether T will release L or not (i.e. not necessarily).

    1. the scheduler transfers T from the Running state to the Runnable state     No
    2. T executes a wait() instruction     Yes
    3. T calls (from inside m()) another synchronized method of C     No
    4. T executes a notify() or a notifyAll() instruction     No

  2. [Pts 2]  In Java, the instruction notify(), executed on an object x of class C, has the following effect (only one answer, please)

    1. One arbitrary thread in the waiting lists of an arbitrary object of class C is transferred into the Runnable state
    2. One arbitrary thread in the waiting list of x is transferred into the Running state, all the other waiting threads in the waiting list of x are transferred into the Runnable state.
    3. One arbitrary thread in the waiting list of x is transferred into the Runnable state.
    4. One arbitrary thread in the waiting list of x is transferred into the Running state.

  3. [Pts 2]  Suppose that 4 threads execute repeatedly a critical section in which at most 3 threads are allowed to be in at the same time. Which technique would you use to ensure that the requirement is met? (Only one answer, please. Indicate the technique which ensures that the requirement is met and that allows maximal parallelism)

    1. Embed the critical section in a synchronized method
    2. Use a semaphore initialized with parameter 3
    3. Use a semaphore initialized with parameter 4
    4. Use a variable which indicates, in turn, which thread has to be out of the critical section.

  4. [Pts 2]  We say that a system is deadlocked if (only one answer, please)

    1. all the threads are in a waiting state
    2. all the threads are sleeping
    3. the number of threads in the Runnable state is greater than the number of processors available
    4. the number of threads in the Runnable state is greater than the number of resources available