Question: The following question asks you to consider a C program fragment. Threads T1 and T2 con- currently run in the same address space. This question

 The following question asks you to consider a C program fragment.

The following question asks you to consider a C program fragment. Threads T1 and T2 con- currently run in the same address space. This question asks you about the state of the process after both threads have completed in two cases: when T1 runs T1A, and when T1 runs TIBO). In both cases, T2 runs T20). Assume that lock is initially unlocked, and is an xv6 spinlock as described in the lecture notes. Note that x is allocated in the static data segment; you may treat it as if it is on the heap, and assume that it is an aligned 32-bit word. int x = x = 0; void T1A() { x = x + 1; void T1B() { acquire(\&lock); x = x + 1; release (\&lock); } void T2() { int r1 = x; } 49. Consider the possible values that r1 could have when T2 completes, and mark the following statement as true or false: Whether T1 runs T1A() or TIB() does not change the possible values T2 can have in rl when it completes. The following question asks you to consider a C program fragment. Threads T1 and T2 con- currently run in the same address space. This question asks you about the state of the process after both threads have completed in two cases: when T1 runs T1A, and when T1 runs TIBO). In both cases, T2 runs T20). Assume that lock is initially unlocked, and is an xv6 spinlock as described in the lecture notes. Note that x is allocated in the static data segment; you may treat it as if it is on the heap, and assume that it is an aligned 32-bit word. int x = x = 0; void T1A() { x = x + 1; void T1B() { acquire(\&lock); x = x + 1; release (\&lock); } void T2() { int r1 = x; } 49. Consider the possible values that r1 could have when T2 completes, and mark the following statement as true or false: Whether T1 runs T1A() or TIB() does not change the possible values T2 can have in rl when it completes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!