Spring 2001, CSE 428: Quiz 7.4 - 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 the next instruction of a thread T in the Runnable state is the call of a synchronized method m() on an object x, and hence T needs to acquire the lock of x. For each of the following cases, say whether T will acquire the lock or not (i.e. not necessarily).

    1. the scheduler transfers T from the Runnable state to the Running state     No
    2. some other thread executes a notifyAll() instruction on x     No
    3. T is transferred to the Running state and the lock of x is free (and will remain free until the execution of T starts)     Yes
    4. the first instruction of m() is of the form while (c) wait(), and c is true     No

  2. [Pts 2]  Assume that a Running thread T calls a method m() on an object x, and that m() contains an instruction while (!c) wait(). Say what will be the effect of this instruction (only one answer, please)

    1. if c is false, T suspends. The execution of T will be resumed as soon as c becomes true.
    2. if c is false, T suspends. The execution of T will be resumed as soon as some other thread executes a notifyAll() on the same object.
    3. if c is false, T releases the lock on x and suspends. When some other thread executes a notifyAll() on the same object, T will be transferred to the runnable state.
    4. if c is false, T releases the lock on x and suspends. When some other thread executes a notifyAll() on the same object, T will be transferred to the running state and receive back the lock.

  3. [Pts 2]  The Java class Applet is characterized by (only one answer, please)

    1. the methods init(), start(), stop() and destroy()
    2. the methods run() and start()
    3. some methods for managing the graphical interface
    4. some methods for the run-time generation of html code

  4. [Pts 2]  Consider the solution to the problem of the dining philosophers obtained by requiring the philosophers with even number to pick up their left fork first, and the philosophers with odd number to pick up their right fork first. Say what of the following cases holds for this solution (only one answer please)

    1. it does not guarrantee deadlock-freedom
    2. it guarrantees deadlock-freedom but not starvation-freedom
    3. it guarrantees both deadlock-freedom and starvation-freedom