Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is a race condition in operating systems ?

  • A.Competition between processes for CPU time
  • B.Multiple processes accessing shared data concurrently
  • C.Processes waiting for I/O completion
  • D.Priority inversion in scheduling

Answer: B

A race condition is multiple processes accessing shared data concurrently, so that the result depends on the timing.

If two threads both read a counter, add one and write it back, their steps can interleave so that one update is lost, and the final value depends on which ran first. Code that touches shared data must be a critical section protected by mutual exclusion, with locks, semaphores or atomic operations.

Competition for the CPU is handled by the scheduler and is not a race condition. Waiting for I/O is ordinary blocking. Priority inversion is a different scheduling problem, where a high-priority task waits on a lower-priority one.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.