Deck 6: Synchronization Tools
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/61
Play
Full screen (f)
Deck 6: Synchronization Tools
1
Which of the following regarding mutex lock is NOT true?
A) mutex lock is a hardware solution to critical-section problem
B) mutex lock is a higher-level software solution to critical-section problem
C) mutex lock suffers from busy waiting
D) the general rule of thumb is to use a mutex lock if the lock will be held for a duration less than two context switches
A) mutex lock is a hardware solution to critical-section problem
B) mutex lock is a higher-level software solution to critical-section problem
C) mutex lock suffers from busy waiting
D) the general rule of thumb is to use a mutex lock if the lock will be held for a duration less than two context switches
A
2
Assume count is a variable name, which of the following operations is atomic?
A) count++
B) count--
C) both of the above
D) none of the above
A) count++
B) count--
C) both of the above
D) none of the above
D
3
Which of the following is not true about test_and_set instruction?
A) It is a hardware instruction
B) It is executed atomically
C) Returns the original value of passed parameter
D) Returns the new value of passed parameter
E) Set the new value of passed parameter to "TRUE"
A) It is a hardware instruction
B) It is executed atomically
C) Returns the original value of passed parameter
D) Returns the new value of passed parameter
E) Set the new value of passed parameter to "TRUE"
D
4
In _________, the process requests permission to access and modify variables shared with others.
A) entry section
B) critical section
C) exit section
D) remainder section
A) entry section
B) critical section
C) exit section
D) remainder section
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following critical-section problem's requirements ensures programs will cooperatively determine what process will next enter its critical section?
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following is true for race condition?
A) race condition occurs where several processes access and manipulate the same data concurrently
B) when race condition occurs, the outcome of the execution depends on the particular order in which the access takes place
C) both of the above
D) none of the above
A) race condition occurs where several processes access and manipulate the same data concurrently
B) when race condition occurs, the outcome of the execution depends on the particular order in which the access takes place
C) both of the above
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following actions should be performed among cooperating processes?
A) process synchronization
B) coordination
C) both of the above
D) none of the above
A) process synchronization
B) coordination
C) both of the above
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following variables are shared between the processes in Peterson's solution?
A) int turn
B) boolean flag[2]
C) both of the above
D) none of the above
A) int turn
B) boolean flag[2]
C) both of the above
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following critical-section problem's requirements ensures only one process is active in its critical section at a time?
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following is true regarding the requirements for the solutions to critical-section problem?
A) mutual exclusion implies progress
B) progress implies bounded waiting
C) bounded waiting implies progress
D) none of the above
A) mutual exclusion implies progress
B) progress implies bounded waiting
C) bounded waiting implies progress
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
11
Assume the binary variable lock is initialized to be 0, which of the following can be an implementation of the entry section to solve the critical-section problem?
A) while (compare and swap(&lock, 0, 1) != 0), do nothing;
B) while (test and set(&lock)), do nothing;
C) both A and B
D) none of the above
A) while (compare and swap(&lock, 0, 1) != 0), do nothing;
B) while (test and set(&lock)), do nothing;
C) both A and B
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following indicates that Pi can enter the critical section in Peterson's solution?
A) flag[j] == false or turn == i
B) flag[j] == true or turn == i
C) flag[j] == false or turn == j
D) flag[j] == true and turn == j
A) flag[j] == false or turn == i
B) flag[j] == true or turn == i
C) flag[j] == false or turn == j
D) flag[j] == true and turn == j
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is a software-based solution to the critical-section problem?
A) Peterson's solution
B) test_and_set
C) compare_and_swap
D) all of the above
A) Peterson's solution
B) test_and_set
C) compare_and_swap
D) all of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is not true about compare_and_swap instruction?
A) It is a hardware instruction
B) It is executed atomically N) Returns the original value of passed parameter
D) Set the new value of passed parameter to "TRUE"
E) Set the variable "value" the value of the passed parameter "new_value" but only if "value" =="expected"
A) It is a hardware instruction
B) It is executed atomically N) Returns the original value of passed parameter
D) Set the new value of passed parameter to "TRUE"
E) Set the variable "value" the value of the passed parameter "new_value" but only if "value" =="expected"
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following critical-section problem's requirements limits the amount of time a program will wait before it can enter its critical section?
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
A) mutual exclusion
B) progress
C) bounded waiting
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following solutions needs hardware support for the critical section problem?
A) memory barriers
B) compare_and_swap instruction
C) atomic variables
D) all of the above
A) memory barriers
B) compare_and_swap instruction
C) atomic variables
D) all of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following is NOT true for Peterson's solution?
A) Mutual exclusion is preserved
B) The progress requirement is satisfied
C) The bounded-waiting requirement is met
D) Peterson's solution works for synchronization among more than two processes
A) Mutual exclusion is preserved
B) The progress requirement is satisfied
C) The bounded-waiting requirement is met
D) Peterson's solution works for synchronization among more than two processes
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
18
When mutex lock is implemented as a binary semaphore, what should its value be initialized to be?
A) 0
B) 1
C) -1
D) none of the above
A) 0
B) 1
C) -1
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is true for the solutions to critical-section problems?
A) No deadlock implies progress, and progress implies bounded waiting
B) Bounded waiting implies progress, and progress implies no deadlock
C) Progress implies no deadlock, and no deadlock implies bounded waiting
D) Bounded waiting implies no deadlock, and no deadlock implies progress
A) No deadlock implies progress, and progress implies bounded waiting
B) Bounded waiting implies progress, and progress implies no deadlock
C) Progress implies no deadlock, and no deadlock implies bounded waiting
D) Bounded waiting implies no deadlock, and no deadlock implies progress
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
20
In _________, the process may be changing common variables, updating a table, writing a file, and so on.
A) entry section
B) critical section
C) exit section
D) remainder section
A) entry section
B) critical section
C) exit section
D) remainder section
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
21
What is the correct order of operations for protecting a critical section using a binary semaphore?
A) release() followed by acquire()
B) acquire() followed by release()
C) wait() followed by signal()
D) signal() followed by wait()
A) release() followed by acquire()
B) acquire() followed by release()
C) wait() followed by signal()
D) signal() followed by wait()
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
22
Explain what busy waiting is.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
23
The counting semaphore is initialized to ___________.
A) 0
B) 1
C) the number of resources available
D) none of the above
A) 0
B) 1
C) the number of resources available
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
24
What is the difference between counting semaphore and binary semaphore.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following statements is true?
A) A counting semaphore can never be used as a binary semaphore.
B) A binary semaphore can never be used as a counting semaphore.
C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore.
D) Counting semaphores can be used to control access to a resource with a finite number of instances.
A) A counting semaphore can never be used as a binary semaphore.
B) A binary semaphore can never be used as a counting semaphore.
C) Spinlocks can be used to prevent busy waiting in the implementation of semaphore.
D) Counting semaphores can be used to control access to a resource with a finite number of instances.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
26
Under which of the following contention loads does traditional synchronization become faster than CAS-based synchronization?
A) uncontended
B) moderate contention
C) high contention
D) none of the above
A) uncontended
B) moderate contention
C) high contention
D) none of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
27
What is meant by "short duration"?
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following is NOT true regarding semaphore implementation?
A) It suffers from the busy waiting problem
B) Semaphore has a waiting queue associated with the semaphore
C) When a process executes the wait() operation and finds that the semaphore value is not positive, it will suspend itself
D) A process that is suspended, waiting on the semaphore, should be restarted when some other process executes a signal() operation.
A) It suffers from the busy waiting problem
B) Semaphore has a waiting queue associated with the semaphore
C) When a process executes the wait() operation and finds that the semaphore value is not positive, it will suspend itself
D) A process that is suspended, waiting on the semaphore, should be restarted when some other process executes a signal() operation.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following is true?
A) No deadlock implies no starvation;
B) No starvation implies no deadlock;
C) Deadlock doesn't imply starvation;
D) Starvation implies deadlock.
A) No deadlock implies no starvation;
B) No starvation implies no deadlock;
C) Deadlock doesn't imply starvation;
D) Starvation implies deadlock.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following may cause a liveness failure?
A) an infinite loop
B) a busy waiting loop
C) a deadlock
D) all of the above
A) an infinite loop
B) a busy waiting loop
C) a deadlock
D) all of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
31
What is the difference between semaphore and mutex lock?
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following are efforts to towards developing scalable, efficient tools that address the demands of concurrent programming?
A) designing compilers that generate more efficient code
B) developing languages that provide support for concurrent programming
C) improving the performance of existing libraries and APIs
D) all of the above
A) designing compilers that generate more efficient code
B) developing languages that provide support for concurrent programming
C) improving the performance of existing libraries and APIs
D) all of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
33
Explain how semaphore implementation overcomes the busy waiting problem of mutex lock.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
34
Assume you had a function named update() that updates shared data. Illustrate how a mutex lock named mutex might be used to prevent a race condition in update().
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
35
Explain what critical section problem is.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
36
Explain two general approaches to handle critical sections in operating systems.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is NOT true?
A) Since semaphore and mutex lock are tools for synchronization, process that have used semaphores or mutex locks should not cause deadlocks
B) Semaphores and mutex locks may be shared resources that difference processes contend for, and hence deadlocks may occur
C) a set of processes is in a deadlocked state when every process in the set is waiting for an event that can be caused only by another process in the set
D) all of the above
A) Since semaphore and mutex lock are tools for synchronization, process that have used semaphores or mutex locks should not cause deadlocks
B) Semaphores and mutex locks may be shared resources that difference processes contend for, and hence deadlocks may occur
C) a set of processes is in a deadlocked state when every process in the set is waiting for an event that can be caused only by another process in the set
D) all of the above
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
38
Explain what race condition is.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following is NOT true regarding conditional variable, e.g. x?
A) The only operations that can be invoked on a condition variable are wait() and signal()
B) x.wait() means that the process invoking this operation is suspended until another process invokes x.signal()
C) The x.signal() operation resumes exactly one suspended process
D) If no process is suspended, then the signal() operation still affects the state of the semaphore
A) The only operations that can be invoked on a condition variable are wait() and signal()
B) x.wait() means that the process invoking this operation is suspended until another process invokes x.signal()
C) The x.signal() operation resumes exactly one suspended process
D) If no process is suspended, then the signal() operation still affects the state of the semaphore
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
40
What three conditions must be satisfied in order to solve the critical section problem?
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
41
Mutex locks and counting semaphores are essentially the same thing.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
42
Semaphore implementation overcomes the busy waiting problem.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
43
Semaphores and mutex locks both provide mutual exclusion.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
44
A semaphore has an integer value.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
45
The preemptive kernel is more suitable for real-time programming than non-preemptive kernel.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
46
Write two short methods that implement the simple semaphore wait() and signal() operations on global variable S.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
47
Solutions to the critical section problem may suffer from liveness failures.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
48
The value of a counting semaphore can range only between 0 and 1.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
49
Peterson's solution works on modern computer architectures.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
50
A monitor is an abstract data type that is based on semaphore implementation.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
51
A mutex lock is released immediately after entering a critical section.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
52
What is the difference between a semaphore and conditional variable?
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
53
Spinlocks are not appropriate for single-processor systems.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
54
Explain what a deadlock is.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
55
When the mutex lock is implemented based on a binary semaphore, it should be initialized to be 0.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
56
The preemptive kernel may be more responsive than non-preemptive kernel.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
57
Race conditions can result in corrupted values of shared data.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
58
Mutex lock variable is binary.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
59
Bounded waiting implies progress, and progress implies mutual exclusion.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
60
Every object in Java has associated with it a single lock.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck
61
CAS-based synchronization is always faster than traditional synchronization.
Unlock Deck
Unlock for access to all 61 flashcards in this deck.
Unlock Deck
k this deck