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 15, val_1 is 45, val_2 is 25, and val_3 is 5. Core 1: Total = Total + val_1; Core 2: Total = Total - val_2; Core 3: Total = Total + val_3; 1. Show the assembly code for both instructions. Assume that Total, var_1, and var_2 are stored at 0x0100, 0x0120, and 0x0130 respectively. 2. 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. 3. 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 15, val_1 is 45, val_2 is 25, and val_3 is 5.
Core 1: Total = Total + val_1;
Core 2: Total = Total - val_2;
Core 3: Total = Total + val_3;
1. Show the assembly code for both instructions. Assume that Total, var_1, and var_2 are stored at 0x0100, 0x0120, and 0x0130 respectively.
2. 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.
3. 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 with 2 images