Answered step by step
Verified Expert Solution
Question
1 Approved Answer
17. Consider the solution to the Producer-Consumer problem that we have studied in Synchronization. As you are aware that this solution uses a shared
17. Consider the solution to the Producer-Consumer problem that we have studied in Synchronization. As you are aware that this solution uses a shared variable counter that is used by both the Producer and the Consumer processes. You may refer to your class notes/book for having a look at the pseudocode. For this problem, assume BUFFER_SIZE = 15. The rest of the producer-consumer code is same as that we had discussed during lecture. Suppose that there is only one producer process and one consumer process. Both processes are executing concurrently. Currently, counter = 8. At the machine language level, counter++ and counter-- are implemented in the same manner that we have discussed in class. Producer uses register and consumer uses register2. Now consider the following sequence of interleaved machine-level instructions shown in the Table below. What is the final value of the counter variable? Only write the answer. You do not have to show any calculation or give any explanation. Time Instant To T T2 T3 T4 Ts Execution consumer executes register2 = counter consumer executes register2 = register2 - 1 producer executes register1 = counter consumer executes counter = register2 producer executes register1 = register1 + 1 producer executes counter = register1
Step by Step Solution
★★★★★
3.41 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
Based on the given sequence of interleaved machinelevel instructions lets analyze the c...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