Deck 5: Exploring Thread Synchronization and Mutual Exclusion in Java

Full screen (f)
exit full mode
Question
Threads that operate independently of one another but must occasionally interact to perform cooperative tasks are said to execute ________.

A) synchronously
B) in parallel
C) asynchronously
D) simultaneously
Use Space or
up arrow
down arrow
to flip the card.
Question
Preventing more than one thread from accessing a shared variable simultaneously is known as ________ access to the shared variable.

A) excluding
B) synchronizing
C) serializing
D) protecting
Question
________ restricts access to a shared variable to only one thread at any given time.

A) asynchronism
B) serialization
C) protection
D) mutual exclusion
Question
An example of a producer/consumer relationship is ________.

A) an application that copies data from a fixed-size buffer to a CD-RW
B) a word processor that sends data to a buffer to be printed
C) both a and b
D) none of the above
Question
In Java, Object method notify transitions a thread from the ________ state to the ________ state.

A) waiting, ready
B) blocked, waiting
C) running, waiting
D) ready, running
Question
In Java, the sleep method call must appear in part of a ________ statement because it might throw an exception indicating that the thread was interrupted before its sleep time expired.

A) if...else
B) do...while
C) try...catch
D) switch
Question
Which of the following statements about critical sections is false?

A) Only one thread at a time can execute the instructions in its critical section for a particular resource.
B) If one thread is already in its critical section, another thread must wait for the executing thread to exit its critical section before continuing.
C) Once a thread has exited its critical section, a waiting thread may enter its critical section.
D) All threads must wait whenever any critical section is occupied.
Question
Code inside a critical section should ________.

A) access shared, modifiable data
B) run as quickly as possible
C) prevent the possibility of infinite loops
D) all of the above
Question
The constructs that encapsulate a thread's critical section are sometimes called ________.

A) critical section primitives
B) synchronism delimiters
C) mutual exclusion primitives
D) protection delimiters
Question
Which property of mutual exclusion primitives is inappropriate for multiprocessor systems?

A) The solution is implemented purely in software on a machine without specially designed mutual exclusion machine-language instructions.
B) No assumption can be made about the relative speeds of asynchronous concurrent threads.
C) A thread that is executing instructions outside its critical section cannot prevent any other threads from entering their critical sections.
D) A thread must not be indefinitely postponed from entering its critical section.
Question
A thread that uses processor cycles to continually test a condition before entering its critical section is said to be ________.

A) lockstep synchronized
B) deadlocked
C) busy waiting
D) indefinitely postponed
Question
Lockstep synchronization does not ________.

A) occur when threads must enter and leave their critical sections in strict alternation
B) improve the efficiency of a process by forcing threads to operate at the same speed
C) force faster threads to operate at the same speed as slower threads
D) occur as a result of using a single variable to govern access to threads' critical sections
Question
________ occurs when an infinite loop prevents progress in a multithreaded application.

A) Lockstep synchronization
B) Deadlock
C) Busy waiting
D) Indefinite postponement
Question
Lamport's Bakery Algorithm does not require ________.

A) a large number of shared variables
B) complicated loops
C) that any operations occur atomically
D) all of the above
Question
Which of the following statements about Lamport's Bakery Algorithm is false?

A) Lamport's algorithm allows multiple threads to obtain the same ticket number.
B) The thread possessing the ticket with the highest numerical value can enter its critical section.
C) Lamport's algorithm enforces mutual exclusion.
D) A thread's ticket number is reset when the thread exits its critical section.
Question
Which of the following mutual exclusion algorithms require instructions to be executed atomically?

A) Dekker's algorithm
B) Peterson's algorithm
C) Lamport's algorithm
D) both a and b
Question
Disabling interrupts ________.

A) is a viable solution for mutual exclusion in a multiprocessor system
B) on a uniprocessor system could result in an infinite loop causing the system to hang
C) typically prevents a thread from being preempted while accessing shared data
D) both b and c
Question
A ________ is a variable that governs access to critical sections.

A) primitive
B) lock
C) controller
D) flag
Question
The test-and-set instruction ________.

A) prevents deadlock
B) prevents indefinite postponement
C) eliminates the possibility that a thread is preempted between reading a value from a memory location and writing a new value to the memory location
D) none of the above
Question
Many system architectures support a(n) ________ instruction that enables a thread to exchange the values of two variables atomically.

A) swap
B) test-and-set
C) semaphore
D) switch
Question
Which of the following statements about semaphores is false?

A) A thread performs the P operation after it enters its critical section.
B) A thread performs the V operation before exiting its critical section.
C) Initializing a semaphore sets the value of a protected variable to indicate that no thread is executing its critical section.
D) Initializing a semaphore creates a queue that stores references to threads waiting to enter their critical sections protected by that semaphore.
Question
What happens when a thread calls P( S ) when it wants to enter its critical section, where S is a binary semaphore set to 1?

A) The thread is allowed to enter its critical section and S is decremented.
B) The thread is blocked and added to a queue of waiting threads.
C) The semaphore is set to 2.
D) none of the above
Question
Which of the following statements about semaphores is true?

A) P and V operations should be indivisible operations.
B) If several threads attempt a P( S ) operation simultaneously, only one thread should be allowed to proceed.
C) A semaphore implementation should guarantee that threads do not suffer indefinite postponement.
D) all of the above
Question
Semaphores can be used for each of the following purposes except:

A) to protect access to a critical section
B) to notify the process that an event has occurred
C) to prevent shared variables from getting corrupted
D) to synchronize two or more concurrent threads
Question
If a thread attempts a P operation when a counting semaphore has been decremented to zero, ________.

A) the thread obtains a resource from the pool and decrements the semaphore to -1
B) the thread obtains a resource from the pool and the semaphore remains equal to 0
C) the thread must wait until a resource is returned to the pool by a V operation
D) the thread returns a resource to the pool and increments the semaphore to 1
Question
Semaphore operations can be implemented in the kernel of a multiprocessor system by:

A) giving one processor the job of controlling the ready list.
B) controlling access (via busy waiting) to a shared ready list.
C) both a and b
D) none of the above
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/26
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Exploring Thread Synchronization and Mutual Exclusion in Java
1
Threads that operate independently of one another but must occasionally interact to perform cooperative tasks are said to execute ________.

A) synchronously
B) in parallel
C) asynchronously
D) simultaneously
C
2
Preventing more than one thread from accessing a shared variable simultaneously is known as ________ access to the shared variable.

A) excluding
B) synchronizing
C) serializing
D) protecting
C
3
________ restricts access to a shared variable to only one thread at any given time.

A) asynchronism
B) serialization
C) protection
D) mutual exclusion
D
4
An example of a producer/consumer relationship is ________.

A) an application that copies data from a fixed-size buffer to a CD-RW
B) a word processor that sends data to a buffer to be printed
C) both a and b
D) none of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
5
In Java, Object method notify transitions a thread from the ________ state to the ________ state.

A) waiting, ready
B) blocked, waiting
C) running, waiting
D) ready, running
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
6
In Java, the sleep method call must appear in part of a ________ statement because it might throw an exception indicating that the thread was interrupted before its sleep time expired.

A) if...else
B) do...while
C) try...catch
D) switch
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements about critical sections is false?

A) Only one thread at a time can execute the instructions in its critical section for a particular resource.
B) If one thread is already in its critical section, another thread must wait for the executing thread to exit its critical section before continuing.
C) Once a thread has exited its critical section, a waiting thread may enter its critical section.
D) All threads must wait whenever any critical section is occupied.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
8
Code inside a critical section should ________.

A) access shared, modifiable data
B) run as quickly as possible
C) prevent the possibility of infinite loops
D) all of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
9
The constructs that encapsulate a thread's critical section are sometimes called ________.

A) critical section primitives
B) synchronism delimiters
C) mutual exclusion primitives
D) protection delimiters
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
10
Which property of mutual exclusion primitives is inappropriate for multiprocessor systems?

A) The solution is implemented purely in software on a machine without specially designed mutual exclusion machine-language instructions.
B) No assumption can be made about the relative speeds of asynchronous concurrent threads.
C) A thread that is executing instructions outside its critical section cannot prevent any other threads from entering their critical sections.
D) A thread must not be indefinitely postponed from entering its critical section.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
11
A thread that uses processor cycles to continually test a condition before entering its critical section is said to be ________.

A) lockstep synchronized
B) deadlocked
C) busy waiting
D) indefinitely postponed
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
12
Lockstep synchronization does not ________.

A) occur when threads must enter and leave their critical sections in strict alternation
B) improve the efficiency of a process by forcing threads to operate at the same speed
C) force faster threads to operate at the same speed as slower threads
D) occur as a result of using a single variable to govern access to threads' critical sections
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
13
________ occurs when an infinite loop prevents progress in a multithreaded application.

A) Lockstep synchronization
B) Deadlock
C) Busy waiting
D) Indefinite postponement
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
14
Lamport's Bakery Algorithm does not require ________.

A) a large number of shared variables
B) complicated loops
C) that any operations occur atomically
D) all of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following statements about Lamport's Bakery Algorithm is false?

A) Lamport's algorithm allows multiple threads to obtain the same ticket number.
B) The thread possessing the ticket with the highest numerical value can enter its critical section.
C) Lamport's algorithm enforces mutual exclusion.
D) A thread's ticket number is reset when the thread exits its critical section.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following mutual exclusion algorithms require instructions to be executed atomically?

A) Dekker's algorithm
B) Peterson's algorithm
C) Lamport's algorithm
D) both a and b
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
17
Disabling interrupts ________.

A) is a viable solution for mutual exclusion in a multiprocessor system
B) on a uniprocessor system could result in an infinite loop causing the system to hang
C) typically prevents a thread from being preempted while accessing shared data
D) both b and c
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
18
A ________ is a variable that governs access to critical sections.

A) primitive
B) lock
C) controller
D) flag
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
19
The test-and-set instruction ________.

A) prevents deadlock
B) prevents indefinite postponement
C) eliminates the possibility that a thread is preempted between reading a value from a memory location and writing a new value to the memory location
D) none of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
20
Many system architectures support a(n) ________ instruction that enables a thread to exchange the values of two variables atomically.

A) swap
B) test-and-set
C) semaphore
D) switch
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements about semaphores is false?

A) A thread performs the P operation after it enters its critical section.
B) A thread performs the V operation before exiting its critical section.
C) Initializing a semaphore sets the value of a protected variable to indicate that no thread is executing its critical section.
D) Initializing a semaphore creates a queue that stores references to threads waiting to enter their critical sections protected by that semaphore.
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
22
What happens when a thread calls P( S ) when it wants to enter its critical section, where S is a binary semaphore set to 1?

A) The thread is allowed to enter its critical section and S is decremented.
B) The thread is blocked and added to a queue of waiting threads.
C) The semaphore is set to 2.
D) none of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following statements about semaphores is true?

A) P and V operations should be indivisible operations.
B) If several threads attempt a P( S ) operation simultaneously, only one thread should be allowed to proceed.
C) A semaphore implementation should guarantee that threads do not suffer indefinite postponement.
D) all of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
24
Semaphores can be used for each of the following purposes except:

A) to protect access to a critical section
B) to notify the process that an event has occurred
C) to prevent shared variables from getting corrupted
D) to synchronize two or more concurrent threads
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
25
If a thread attempts a P operation when a counting semaphore has been decremented to zero, ________.

A) the thread obtains a resource from the pool and decrements the semaphore to -1
B) the thread obtains a resource from the pool and the semaphore remains equal to 0
C) the thread must wait until a resource is returned to the pool by a V operation
D) the thread returns a resource to the pool and increments the semaphore to 1
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
26
Semaphore operations can be implemented in the kernel of a multiprocessor system by:

A) giving one processor the job of controlling the ready list.
B) controlling access (via busy waiting) to a shared ready list.
C) both a and b
D) none of the above
Unlock Deck
Unlock for access to all 26 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 26 flashcards in this deck.