Practice mode Operating Systems

Two threads each run count = count + 1 on a shared variable without synchronisation, and the final value is sometimes wrong. What is this called?

Correct answer C. A race condition

Explanation

count = count + 1 is a load, an add and a store; if the threads interleave between those steps, one update can overwrite the other. When the outcome depends on the precise timing of accesses to shared data, that is a race condition. Deadlock is processes waiting for each other forever, and starvation is one process being postponed indefinitely.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.