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