---
title: "Race condition; mutual exclusion requirements"
subject: "Operating System"
chapter: 3
key: "semester_6/operating_system:race-mutual-exclusion-requirements"
source: https://www.bctengineer.com/q/semester_6/operating_system/race-mutual-exclusion-requirements
site: BCT Engineering
---

# Race condition; mutual exclusion requirements

Operating System · Chapter 3: Process Communication and Synchronization

- Asked in: 2075 Baisakh, 2+3 marks
- Video: [Race Condition Explained Using Analogy | Operating System | 6 Minutes](https://www.youtube.com/watch?v=DNMhoN-aIiE) — Engineering Analogies
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/race-mutual-exclusion-requirements
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-3

## Question

What is race condition and Mutual Exclusion? List the requirements that a solution to solve race condition should satisfy.

## Short answer

A race condition occurs when the final result of concurrent shared data access depends on process scheduling order. Mutual exclusion guarantees that at most one process enters its critical region at a time. Any solution must provide mutual exclusion, progress (a process outside its critical section cannot prevent others from entering), and bounded waiting (no process waits indefinitely).

## Answer

#### Race condition
A **race condition** occurs when two or more processes access and modify shared data concurrently and the outcome depends on the order of execution. Example: two processes doing `x = x + 1` on a shared `x = 5` may both read 5 and both write 6, instead of 7.

#### Mutual exclusion
**Mutual exclusion** is the guarantee that when one process is executing in its critical section (the code using shared data), no other process can execute in its critical section. It is the way to prevent race conditions.

#### Requirements of a good solution (Tanenbaum's four conditions)
1. **Mutual exclusion:** no two processes may be inside their critical regions at the same time.
2. **No assumptions about speed or number of CPUs:** the solution must not depend on relative process speeds.
3. **Progress:** no process running outside its critical region may block another process from entering.
4. **Bounded waiting (no starvation):** no process should wait forever to enter its critical region.

(Silberschatz states these as mutual exclusion, progress and bounded waiting.)

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Two processes do x = x + 1 on shared x = 5, both reading 5 before either writes. What is the final value?
   A. 8
   B. 6, instead of 7
   C. 7
   D. 5
   Answer: B. Both write 6, so one update is lost. (Key point: Race condition)

2. What does mutual exclusion guarantee?
   A. All processes run in the same order every time
   B. When one process is in its critical section, no other can be in theirs
   C. Processes never share data
   D. Each process gets equal CPU time
   Answer: B. It prevents simultaneous access to shared data and hence race conditions. (Key point: Mutual exclusion)

3. Which requirement says a process outside its critical region must not block others from entering?
   A. Bounded waiting
   B. Mutual exclusion
   C. Progress
   D. Speed independence
   Answer: C. Progress forbids processes in their remainder section from blocking others. (Key point: Progress)

4. Which requirement prevents starvation?
   A. No assumptions about CPU speed
   B. No process should wait forever to enter its critical region
   C. Processes must be outside critical regions to be blocked
   D. Only one process in the critical region
   Answer: B. Bounded waiting guarantees every process eventually enters. (Key point: Bounded waiting)

## Related in Operating System

- [Critical section; mutual exclusion](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Acritical-section-mutual-exclusion-pc) — Operating System, chapter 3
- [Semaphore for mutual exclusion](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Asemaphore-enforce-mutual-exclusion) — Operating System, chapter 3
- [Race condition; sleep() and wakeup()](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arace-sleep-wakeup) — Operating System, chapter 3
- [Race condition; optimal page replacement limits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arace-condition-optimal-limitation) — Operating System, chapter 3
- [Race condition; critical section approaches](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arace-condition-critical-section-approaches) — Operating System, chapter 3
- [Race condition example; Peterson's algorithm](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Arace-condition-example-peterson) — Operating System, chapter 3

## Related in other subjects

- [Token ring mutual exclusion](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Atoken-ring-mutex) — Distributed System, chapter 6, asked 3×
- [Ricart-Agrawala mutual exclusion](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aricart-agrawala) — Distributed System, chapter 6, asked 2×
- [Lamport algorithm for mutual exclusion](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-mutex) — Distributed System, chapter 6
- [Mutual exclusion via sleep and wake](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Amutual-exclusion-sleep-wake) — Embedded System, chapter 6
