Spring 2001, CSE 428: Quiz 7.2 - 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 2 (morning section).
  1. [Pts 2]  In Java, a thread tries to acquire a lock when (only one answer, please)

    1. It tries to call a synchronized method
    2. It tests a boolean condition followed by a wait() instruction
    3. It tries to create an object of a class protected by a lock
    4. It tries to send a notification to a thread holding the lock

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

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

  3. [Pts 3]  Suppose that two threads T1 and T2 share one resource R, and each of them needs that resource to perform a certain task. They are supposed to execute their task repeatedly. The resource should be used only by one thread at the time (mutual exclusion on R). Classify each of the following situations with one of the following words: deadlock, livelock, violation of strong fairness, violation of weak fairness, violation of mutual exclusion.

    1. There is no synchronization on the methods, nor use of a semaphore, hence both T1 and T2 can access R at the same time.     Violation of mutual exclusion
    2. T2 is always quicker than T1 in acquiring R, hence T1 can never perform its task.     Violation of strong fairness or Livelock (both answers are acceptable)
    3. T1 and T2 are in the Runnable state, but they never get scheduled (for instance because the implementation is not very well designed).     Violation of weak fairness

  4. [Pts 2]  We say that a thread is in busy waiting if it is (only one answer, please)

    1. in the Running or Runnable state, testing for the verification of some condition
    2. in the waiting list of an object, testing for the verification of some condition on that object
    3. in the Suspended state, waiting to be resumed by some other thread,
    4. in the waiting list of an object, waiting to be notified by some other thread