Consider the following multi-threaded pseudocode. Thread A: 1. lock (& mutex); 2. if( queue empty ()) { 3. cond_wait (&cv, & mutex); 4.] 5. data = queue.pop(): 6. unlock (& mutex); Thread B: 1. lock (& mutex); 2. queue insert (data); 3. cond signal (& cv); 4. unlock (& mutex); A. Thread A Line 2 B. Thread A Line 3 C. Thread B Line 2 D. Thread B Line 3 E. No bugs

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 14VE
icon
Related questions
Question

Can you help me with question 4

Consider the following multi-threaded pseudocode.
Thread A:
1. lock (& mutex);
2. if( queue empty ()) {
3. cond_wait (&cv, & mutex);
4.]
5. data = queue.pop():
6. unlock (& mutex);
Thread B:
1. lock (& mutex);
2. queue insert (data);
3. cond signal (& cv);
4. unlock (& mutex);
Transcribed Image Text:Consider the following multi-threaded pseudocode. Thread A: 1. lock (& mutex); 2. if( queue empty ()) { 3. cond_wait (&cv, & mutex); 4.] 5. data = queue.pop(): 6. unlock (& mutex); Thread B: 1. lock (& mutex); 2. queue insert (data); 3. cond signal (& cv); 4. unlock (& mutex);
A. Thread A Line 2
B. Thread A Line 3
C. Thread B Line 2
D. Thread B Line 3
E. No bugs
Transcribed Image Text:A. Thread A Line 2 B. Thread A Line 3 C. Thread B Line 2 D. Thread B Line 3 E. No bugs
Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning