Consider the following portions of three different programs running at the same time on three processors in a symmetric multicore processor (SMP). Assume that before this code is run,Total is 10, val_1 is 50, val_2 is 15, and val_3 is 5. Core 1: Total = Total + val_1; Core 2: Total = Total - val_2; Core 3: Total = Total + val_3; a) Show the assembly code for both instructions. Assume that Total, var_1, and var_2 are stored at 0x0100, 0x0120, and 0x0130 respectively. b) What are all the possible resulting values of Total? For each possible outcome, explain how we might arrive at those values. You will need to show all possible interleavings of instructions. c) How could you make the execution more deterministic so that only one set of values is possible?
Consider the following portions of three different programs running at the same time on three processors in a symmetric multicore processor (SMP). Assume that before this code is run,Total is 10, val_1 is 50, val_2 is 15, and val_3 is 5.
Core 1: Total = Total + val_1;
Core 2: Total = Total - val_2;
Core 3: Total = Total + val_3;
a) Show the assembly code for both instructions. Assume that Total, var_1, and var_2 are stored at 0x0100, 0x0120, and 0x0130 respectively.
b) What are all the possible resulting values of Total? For each possible outcome, explain how we might arrive at those values. You will need to show all possible interleavings of instructions.
c) How could you make the execution more deterministic so that only one set of values is possible?
Trending now
This is a popular solution!
Step by step
Solved in 2 steps