Quiz 8 Flashcards
An approximate counter represents a logical counter via multiple local physical counters.
True
What is a condition variable?
Just another name for a lock
A queue that allows threads to wait for a condition to become true
A flag that describes whether multiprocessing is enabled
A flag that describes if multiple threads are running
A queue that allows threads to wait for a condition to become true
Semaphores cannot be used to enforce an order in the execution of different threads
False
Select all the statements that apply to semaphores
A semaphore can be used to synchronize threads or processes
A semaphore can be manipulated via lock and a unlock routines
A semaphore can be manipulated via post and a wait routines
A semaphore’s value is always initialized to 1
Correct Answer
A semaphore can be used to synchronize threads or processes
Correct Answer
A semaphore can be manipulated via post and a wait routines
Thread ________ is a technique used to prevent too many threads from concurrently performing a given task.
throttling
Which concurrency bug occurs here?
THREAD 1: if (record->uid) printf(“%s\n”, record->uid);
THREAD 2: record->uid = NULL;
No bug occurs
Use after free
Deadlock
Atomicity violation
Atomicity violation
Which primitives can be used to implement a lock? Mark all that applies
fetch and add
vpn-to-pfn
compare-and-swap
test-and-set
fetch and add
compare-and-swap
test-and-set
Consider a multi-threaded counter implementation which uses a lock to protect the instructions incrementing the counter. This is an efficient way to implement a multi-threaded counter.
(true or false)
true
A fetch-and- ____ instruction increments a value, while returning the old value at a particular memory location
add
What is a deadlock?
A task which cannot benefit from concurrent execution
A type of lock in which waiting threads are de-scheduled
A situation where a thread terminates without de-initialize a lock
A situation where multiple threads are stuck waiting for each other to release a resource
A situation where multiple threads are stuck waiting for each other to release a resource
Semaphores can be used to implement both locks and condition variables
(True or False)
True
A ____ -and-swap instruction compares a value in memory with an expected value, and if equal updates the memory with a new value.
compare
What does the producer-consumer problem describe?
A situation where one producer thread places items in a buffer, and one consumer thread processes them
A situation where one or more consumer threads place items in a buffer, and one or more producer threads process them
A situation where one or more producer threads place items in a buffer, and one or more consumer threads process them
A situation where one consumer thread places items in a buffer, and one or more producer thread processes them
A situation where one or more producer threads place items in a buffer, and one or more consumer threads process them
A ticket lock guarantees that all threads that attempt to acquire it will eventually succeed
(True or false)
True
A data structure is thread safe if multiple threads will never try to access it concurrently
(True or false)
False