Question: 3 . ( 7 points ) ( a ) Given the following program in which two threads concurrently update one critical resource shared _ data
points
a Given the following program in which two threads concurrently update one critical resource shareddata without using locks Theoretically, how many different final values may shareddata have? Please explain how each different value is attained by giving the running order of the statements eg of the two threads.
l
l
shareddata
rlock threading.RLock
def test:
global shareddata
for in in ranger; ; lock.aq uirell
rlockqqunt local shareddata rlock, relone
Mrkreloselocal local
shareddata local
time.sleep rlock, reqease
t threading.Threadtarget test, args
t threading.Threadtarget test, args
tstart
tstart
tjoin
tjoin
printshareddata
Theoretical Val. of shaveddata
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
