Spring 2001, CSE 428: Quiz 7.1 - 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]  A lock in Java is associated with (only one answer, please)

    1. A synchronized method
    2. A class with at least one synchronized method
    3. An object of a class with at least one synchronized method
    4. A thread calling a synchronized method

  2. [Pts 2]  The instruction wait() in Java has the following effect (only one answer, please)

    1. The thread executing wait() releases the lock and it is inserted in the waiting list of the object
    2. The object on which the wait() is executed is inserted in the waiting list of the thread
    3. The thread executing wait() suspends until a certain boolean condition becomes true
    4. The thread executing wait() releases the lock and goes from the Running to the Runnable state

  3. [Pts 2]  The typical purpose of a semaphore is (only one answer, please)

    1. To protect the access to a critical section C by allowing only one thread at a time to be in C.
    2. To protect the access to a critical section C by allowing only a certain number of threads (established by a given parameter) to be in C at the same time.
    3. To ensure that certain threads (given as parameters) can never enter a certain critical section.
    4. To protect the access to a critical section by following a "traffic light" strategy: now it's the turn of Thread T1, next is the turn of Thread T2, then it's the turn of Thread T3, and so forth, in a circular fashion.

  4. [Pts 4]  Suppose that two threads T1 and T2 share two resources R1 and R2, and each of them needs both resources to perform a certain task. They are supposed to execute their task repeatedly. 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, interference.

    1. T1 is always quicker than T2 to get both the resources, so only T1 makes progress. (T2 goes repeatedly into the Runnable state, but it is scheduled for execution only when the resources are already held by T1)     Violation of strong fairness
    2. T1 is holding R1 and repeatedly checking whether R2 has been released, and T2 is holding R2 and repeatedly checking whether R1 has been released (both T1 and T2 go repeatedly into the Running state, but they don't get to perform their tasks).     Livelock
    3. T1 is holding R1 and waiting for R2 to be released and T2 is holding R2 and waiting for R1 to be released (T1 is in the wait list of R2 and T2 is in the wait list of R1, hence none of them can go into the Runnable state).     Deadlock
    4. T1 and T2 are in the Runnable state continuously, but they are never scheduled (for instance because the implementation is not very well designed).     Violation of weak fairness