Problemarise..Shared memory-XValue = 10State:State:Register ARegister AValue =10RunningValue=0Ready2.1load memory Xto2.1load memory X toregister A;register A;2.22.2add 1o to register A;minus 1o from register A;2.32.3write register A towrite register A tomemory X;memory X;ProcessAProcessBintelCore"17ExecutionFlow#2,Step116
Problem arise. 16 Process B Shared memory - X Value = 10 State: Running Register A Value = 10 Process A State: Ready Register A Value = 0 2.1 load memory X to register A; 2.2 add 10 to register A; 2.3 write register A to memory X; 2.1 load memory X to register A; 2.2 minus 10 from register A; 2.3 write register A to memory X; Execution Flow #2, Step 1 1
Problemarise..Shared memory-XValue = 10State:Register AState:Register AValue = 10Value = 10ReadyRunning2.1load memory Xto2.1load memory X toregister A;register A;2.22.2add 1o to register A;minus 1o from register A;2.32.3write register A towrite register A tomemory X;memory X;Context SwitchingProcessAProcessBintelCore"i7ExecutionFlow#2,Step217
Problem arise. 17 Process B Shared memory - X Value = 10 Register A Value = 10 Process A Register A Value = 10 2.1 load memory X to register A; 2.2 add 10 to register A; 2.3 write register A to memory X; Execution Flow #2, Step 2 Context Switching State: Ready State: Running 2.1 load memory X to register A; 2.2 minus 10 from register A; 2.3 write register A to memory X; 1 2
Problemarise..Shared memory-XValue = 10State:Register AState:Register AValue =10RunningValue=20Ready2.1load memory X to2.1load memory X toregister A;register A;2.22.2add 1o to register A;minus 1o from register A;2.32.3write register A towrite register A tomemory X;memory X;ContextSwitchingProcessAProcessBintelCore"i7ExecutionFlow#2,Step318
Problem arise. 18 Process B Shared memory - X Value = 10 Register A Value = 20 Process A Register A Value = 10 2.1 load memory X to register A; 2.2 add 10 to register A; 2.3 write register A to memory X; Execution Flow #2, Step 3 2.1 load memory X to register A; 2.2 minus 10 from register A; 2.3 write register A to memory X; Context Switching State: Running State: Ready 1 2 3
Problemarise..Shared memory-XValue = 10State:Register AState:Register AValue=20Value=0ReadyRunning2.1load memory X to2.1load memory X toregister A;register A;2.22.2add 1o to register A;minus 1o from registerA;2.32.3write register A towrite register A tomemory X;memory X;Context SwitchingProcessAProcessBintelCore"i7ExecutionFlow#2,Step419
Problem arise. 19 Process B Shared memory - X Value = 10 Register A Value = 20 Process A Register A Value = 0 2.1 load memory X to register A; 2.2 add 10 to register A; 2.3 write register A to memory X; Execution Flow #2, Step 4 2.1 load memory X to register A; 2.2 minus 10 from register A; 2.3 write register A to memory X; Context Switching State: Ready State: Running 1 2 3 4
Problemarise..Shared memory-XValue = 10State:Register ARegister AState:Value=20Value=0ReadyRunning2.1load memory X to2.1load memory X toregister A;register A;2.22.2add 1o to register A;minus 1o fromregisterA;2.32.3write register A towrite register A tomemory X;memory X;ProcessAHELP!!Nomatterwhichprocessrunsnext,theresultisrocessBeither0or20,butnot10!Thefinal resultdependsontheexecutionseguence!20
Problem arise. 20 Process B Shared memory - X Value = 10 Register A Value = 20 Process A Register A Value = 0 2.1 load memory X to register A; 2.2 add 10 to register A; 2.3 write register A to memory X; 2.1 load memory X to register A; 2.2 minus 10 from register A; 2.3 write register A to memory X; State: Ready State: Running 1 2 3 4 HELP!! No matter which process runs next, the result is either 0 or 20, but not 10! The final result depends on the execution sequence!