Operating systems · 1 min
Why race conditions depend on timing, not speed
Learn how interleaved thread execution leads to lost updates on shared memory and how locks make these critical operations indivisible.
Practise Operating systemsMore videos
The quiz
What is a race condition?
- A bug where the result depends on the timing of threads touching shared data without coordination
- Two processes competing to start first
- A deadlock between exactly two threads
- The scheduler favouring short jobs
Show the answer
A. A bug where the result depends on the timing of threads touching shared data without coordination
Transcript
This interview answer fails because race conditions depend on execution timing, not speed.
Look at count plus plus on shared memory. Inside the CPU, it is a read, an add, and a write back.
If two threads interleave these steps without coordination, both read zero. The first writes one, but the second write causes a lost update.
Now the part most people miss: this timing bug happens on uncoordinated shared data, and because timing varies, it is hard to reproduce.
Locks make operations indivisible. Any valid critical section protocol must strictly guarantee mutual exclusion, actual progress, and bounded waiting for every single thread.
Pause your screen right now and tap your answer: what exactly is a race condition in operating systems? Choose A, B, C, or D.
The correct answer is A. It is all about timing over shared resources; it is not about which thread starts running first.
Locks ensure safety across shared data. Save this video before your technical rounds, and practice these core operating system problems on InternDoor today.