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

Discussion

Which of the following ensures mutual exclusion in concurrent processes ?

  • A.Using unbuffered I/O
  • B.Using atomic test-and-set instructions
  • C.Using environment variables
  • D.Using command-line arguments

Answer: B

Mutual exclusion is ensured by atomic test-and-set instructions.

A test-and-set instruction reads a lock variable and sets it to 1 in a single, indivisible hardware operation. A process enters its critical section only if the old value was 0; any other process that tries at the same moment sees 1 and must wait. Because no other process can slip in between the read and the write, only one process can hold the lock, which is the basis of spinlocks.

Unbuffered I/O only changes how data reaches a device. Environment variables and command-line arguments pass settings to a process when it starts. None of them coordinates access to shared data between running processes.

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

Post your comment

Please log in or register to post a comment.