Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. 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
Step: 1
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