COP 4610 EXAM 2 STUDY GUIDE
monitor is ... - Answer -a lock + condition variables
lock provides... - Answer -mutual exclusion to shared data
condition variable provides.... - Answer -a queue for waiting threads inside a critical
section
what are the three operations for condition variables - Answer -wait, signal, broadcast
how does a hoare monitor work? - Answer -signal() transfers the CPU directly to a
waiting thread.
how does a mesa monitor work? - Answer -signal() only puts a waiting thread on the
scheduler's ready queue
by the time the waken thread gets the CPU, the waiting condition may no longer be true
and needs to be retested.
Structure of reader/writer solution - Answer -Reader: wait until no writers, access
database, wake up waiting writers
Writer: wait until no active readers or writers, access database, wake up waiting readers
or writers
Can you implement monitors with semaphores? - Answer -nope! conditional variables
only work inside a lock, which may cause a deadlock
difference between semaphores and monitors? - Answer -condition variables have
history
def. deadlock - Answer -occur when threads are waiting for resources with circular
dependencies
nonpreemptable resources - Answer -resources which cannot be taken away from its
current thread without failing the computation
deadlocks that involve preemptable resources can usually be resolved by... - Answer -
reallocation of resources
T/F? Deadlocks can be resolved for each resource independently. - Answer -False
T/F? Robin Round cannot prevent deadlocks. - Answer -True
, Deadlock conditions (4): - Answer -(1) Limited access (lock-protected resources)
(2) No preemption (if someone has the resource, it cannot be taken away)
(3) Wait while holding (holding a resource while requesting and waiting for the next
resource)
(4) Circular chain of requests
T/F? If all 4 deadlock conditions are true, there is a deadlock. - Answer -False
T/F? If there is a deadlock, all 4 conditions are true. - Answer -True
To prevent deadlocks - Answer -remove one of the four conditions
Deadlock prevention techniques (8) - Answer -1. Infinite resources
2. No sharing/independent threads
3. Allocate all resources at the beginning
4. Make everyone use the same ordering in accessing resource (All threads must call
P(x) before P(y)).
5. No waiting
6. Preempt resources
7. Banker's algorithm
8. A combination of techniques
Banker's algorithm - Answer -a thread states its maximum resources needs in advance
OS allocates resource dynamically as needed. a thread waits if granting its request
would lead to deadlocks
a request can be granted if some sequential ordering of threads is deadlock free
uniprogramming without memory protection - Answer -each application runs within a
hardwired range of physical memory addresses.
one application runs at a time
when a program is copied into memory, a ___ alters the code of the program - Answer
-linker-loader
memory protection keeps ____ - Answer -user programs from crashing one another
and the OS
monitor is ... - Answer -a lock + condition variables
lock provides... - Answer -mutual exclusion to shared data
condition variable provides.... - Answer -a queue for waiting threads inside a critical
section
what are the three operations for condition variables - Answer -wait, signal, broadcast
how does a hoare monitor work? - Answer -signal() transfers the CPU directly to a
waiting thread.
how does a mesa monitor work? - Answer -signal() only puts a waiting thread on the
scheduler's ready queue
by the time the waken thread gets the CPU, the waiting condition may no longer be true
and needs to be retested.
Structure of reader/writer solution - Answer -Reader: wait until no writers, access
database, wake up waiting writers
Writer: wait until no active readers or writers, access database, wake up waiting readers
or writers
Can you implement monitors with semaphores? - Answer -nope! conditional variables
only work inside a lock, which may cause a deadlock
difference between semaphores and monitors? - Answer -condition variables have
history
def. deadlock - Answer -occur when threads are waiting for resources with circular
dependencies
nonpreemptable resources - Answer -resources which cannot be taken away from its
current thread without failing the computation
deadlocks that involve preemptable resources can usually be resolved by... - Answer -
reallocation of resources
T/F? Deadlocks can be resolved for each resource independently. - Answer -False
T/F? Robin Round cannot prevent deadlocks. - Answer -True
, Deadlock conditions (4): - Answer -(1) Limited access (lock-protected resources)
(2) No preemption (if someone has the resource, it cannot be taken away)
(3) Wait while holding (holding a resource while requesting and waiting for the next
resource)
(4) Circular chain of requests
T/F? If all 4 deadlock conditions are true, there is a deadlock. - Answer -False
T/F? If there is a deadlock, all 4 conditions are true. - Answer -True
To prevent deadlocks - Answer -remove one of the four conditions
Deadlock prevention techniques (8) - Answer -1. Infinite resources
2. No sharing/independent threads
3. Allocate all resources at the beginning
4. Make everyone use the same ordering in accessing resource (All threads must call
P(x) before P(y)).
5. No waiting
6. Preempt resources
7. Banker's algorithm
8. A combination of techniques
Banker's algorithm - Answer -a thread states its maximum resources needs in advance
OS allocates resource dynamically as needed. a thread waits if granting its request
would lead to deadlocks
a request can be granted if some sequential ordering of threads is deadlock free
uniprogramming without memory protection - Answer -each application runs within a
hardwired range of physical memory addresses.
one application runs at a time
when a program is copied into memory, a ___ alters the code of the program - Answer
-linker-loader
memory protection keeps ____ - Answer -user programs from crashing one another
and the OS