Question: DO NOT COPY FROM ANY OTHER CHGG QUESTION, IT'S WRONG II. Consider the following two threads in the same process executing on the same core.

DO NOT COPY FROM ANY OTHER CHGG QUESTION, IT'S WRONG

DO NOT COPY FROM ANY OTHER CHGG QUESTION, IT'S WRONG II. Considerthe following two threads in the same process executing on the same

II. Consider the following two threads in the same process executing on the same core. The value at memory 2000 is initialized to 0 . We also assume that Thread 1 is scheduled to execute first. Thread_2 .main mov $5,%ax .top mov 2000,%dx add $2,%dx mov %dx,2000 sub $1,%ax test $4,%dx jgt .out test $0,%ax jgt .top .out halt Note: the above-used assembly instructions are the same as the x86 assembly introduced in tutorial 3. (a) (5 marks) What is the final value at the memory 2000 if the interrupt is disabled? (b) (5 marks) If the interrupt is enabled (we assume that a thread switches to the other thread when an interrupt occurs), will the two threads see the same final values of %ax after both threads finish their work? If yes, what is the value of % ax seen by the two threads? If not, what are the values of % ax seen by each thread respectively? (c) (5 marks) If an interrupt could occur at any time (i.e., after the execution of any instruction), will the final value in memory 2000 be always the same as the case where the interrupt is disabled? If yes, please explain the reason; if not, which code segment in Thread_1 and Thread_2 needs to be protected (here "protected" means the interrupt is disabled during the execution of that code segment)

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!