Question: Suppose proc 1 and proc 2 run in two separate threads and that each procedure is called in its respective thread exactly once. Variables x
Suppose proc and proc run in two separate threads and that each procedure is called in its respective thread exactly once. Variables x and a are global and shared between threads and x is initialized to Further, assume the increment and decrement operations are atomic. The calls to proc in proc and proc should be replaced with calls to proca and procb depending on the part of the question. a If proc and proc call proca in lines and is the final value of global variable x guaranteed to be Justify your answer. b What if proc and proc call procb Justify your answer. c With proc and proc still calling procb modify proc and proc with condition variable go to guarantee the final value of x is Specifically, give the lines where pthreadcondwait and pthreadcondsignal should be inserted into the code listing. Justify your answer briefly. Make the assumption that proc acquires locka before proc Also recall that pthreadcondwait&go &locka; will temporarily release locka and block the calling thread until pthreadcondsignal&go; is called in another thread, at which point the waiting thread will be unblocked and reacquire locka
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
