Hint: Note that the memory location being accessed by each thread is the same (i.e. it is a shared variable). Think about the access pattern that would result to different threads reading a different data from the shared memory. Q2.1: What is the smallest possible value stored at
θ(sθ)
after two threads finish executing the code? Q2.2: What is the largest possible value stored at
θ(sθ)
after two threads finish executing the code? 3 Q2.3: Now, let's extend it further. What is the largest possible value stored at
θ(sθ)
after four threads finish executing the code? Hint: Answer Q2.2 correctly first to understand the execution pattern needed to get the worst case scenario.