Question:

What is a ‘race condition’ in concurrent programming?

Show Hint

A race condition occurs when the outcome of a program depends on the unpredictable order of execution of threads or processes accessing shared resources.
Updated On: Jun 27, 2025
  • When two processes compete for CPU time
  • When the outcome depends on the unpredictable order of execution of threads
  • When a program terminates unexpectedly
  • When memory allocation fails during execution
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In concurrent programming, a race condition occurs when two or more processes or threads compete to access shared resources, and the outcome of their execution depends on the unpredictable order in which they execute. This can lead to unexpected behavior or bugs, as the result can change depending on the timing of thread execution.
- When two processes compete for CPU time (A) is related to the concept of CPU scheduling, but it is not specifically a race condition.
- When a program terminates unexpectedly (C) is an error that can happen for various reasons, but it is not necessarily related to race conditions.
- When memory allocation fails during execution (D) is an issue with memory management, not a race condition.
Thus, the correct answer is (B), where the outcome depends on thread execution order.
Was this answer helpful?
0
0