Question
Conditional Variable Given a mutex lock mm, and a conditional variable cc, the following events happen in the order of occurrence stated below: T2 executes
Conditional Variable
Given a mutex lock mm, and a conditional variable cc, the following events happen in the order of occurrence stated below:
- T2 executes mutex-lock(m).
- T1 executes mutex-lock(m).
- T2 executes cond-wait(c, m).
- T1 executes cond-signal(c).
- T1T1 executes mutex-unlock(m)
Fill in the boxes below. If there is no thread waiting for a lock or a signal, leave the boxes blank.
Before Step 4
Write down the state of the two waiting queues after steps 1, 2, and 3 are completed.
For the mutex variable mm, write your answers as a comma-separated list with the first entry being the thread that currently has the lock. For example, if T1 has the lock and T2 is waiting for the lock, you should answer "T1, T2". If a queue is empty, write down "NA"
For the conditional variable cc, write a comma-separated list of threads waiting in order that they arrived. For instance, if T1 and T2 are waiting for mutex lock mm, you should answer "T1 m, T2 m."
Mutex variable m=? Conditional variable c=?
Before Step 5
Write down the state of the two waiting queues before step 5. Steps 1, 2, 3, and 4 have completed.
For the mutex variable mm, write your answers as a comma-separated list with the first entry being the thread that currently has the lock. For example, if T1 has the lock and T2 is waiting for the lock, you should answer "T1, T2." If a queue is empty, write down "NA"
For the conditional variable cc, write a comma-separated list of threads waiting in order that they arrived. For instance, if T1 and T2 are waiting for mutex lock mm, you should answer "T1 m, T2 m."
Mutex variable m=? Conditional variable c=?
After All Steps
Write down the state of the two waiting queues after all the steps are completed.
For the mutex variable mm, write your answers as a comma-separated list with the first entry being the thread that currently has the lock. For example, if T1 has the lock and T2 is waiting for the lock, you should answer "T1, T2" If a queue is empty, write down "NA"
For the conditional variable c, write a comma-separated list of threads waiting in order that they arrived.
Mutex variable m=? Conditional variable c=?
Mutex Variable M Thread ID Lock Thread ID Lock Thread ID Lock Conditional Variable Mutex Variable M Thread ID Lock Thread ID Lock Thread ID Lock Conditional VariableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started