4
$\begingroup$

I get confused because i don't know if it is possible to use Test and Set primitives in case where more then one process can be enter in critical section at the same time.

$\endgroup$
1
  • $\begingroup$ Test and Set is a primitive operation, used as a building block to implement more powerful operations. $\endgroup$
    – gnasher729
    Oct 29, 2017 at 7:42

1 Answer 1

5
$\begingroup$

Your hunch is correct, they aren't equivalent. Test-and-set has a consensus number of 2, which means, roughly speaking, that it is only able to efficiently synchronize between 2 processes. See Why is the consensus number for test-and-set, 2?. Semaphores allow synchronization between an arbitrary number of processes (assuming no bound on the number of processes waiting on a semaphore).

It isn't really a “fair” comparison, since test-and-set is a hardware primitive while semaphores are a software interface. But if does show that test-and-set isn't sufficient to implement (wait-free) semaphores.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.