I opened the file [Link] and searched for thread interleaving patterns.
For example, in my
run I saw:
Thread: 50, new value of count: 444053
Thread: 40, new value of count: 443981
Thread: 50, new value of count: 444058
Here the execution switched from Thread 50 → Thread 40 → Thread 50. This shows a
context switch, since the CPU stopped running one thread, scheduled another, and then went
back to the first one.
When I checked the values of count, I noticed that the numbers are not always sequential. For
example, it jumped backward (444053 → 443981) which indicates that two threads were
updating the shared variable shared_counter without mutual exclusion, leading to
inconsistent results. This confirms that the race condition happened and count was not updated
correctly.