What is the difference between mutex and semaphore?

Answer Posted / rufus v. smith

A semaphore can be claimed a preset number of times, and when this number is reached, additional claims are blocked/denied until there is a release.

A binary semaphore has a count of 1. However, this does NOT make it a mutex.

A mutex is thread-aware. Once claimed, other claims (by other threads) will be blocked/denied. However, the same thread may claim it repeatedly and not be blocked (it must be released the same number of times).

For a binary semaphore, a second claim, even from the same thread, WILL block (not a good situation if from the same thread, make sure to timeout the request)

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are wait states used?

602


What is a sector?

516


Can x86 run 64 bit?

530


Can you run 32 bit applications on a 64 bit operating system?

448


What is process communication?

531






Explain mutant in operating system (os)?

546


What are the different raid levels?

605


How does dynamic loading aid in better memory space utilization?

977


Do you know what is a binary semaphore? What is its use?

553


What is the kernel of the operating system?

484


Explain the difference between logical & physical address.

590


What is a 64 bit application?

510


What do you mean by response time and turnaround time?

573


What is drawback of mvt?

571


What is Direct Access Method?

580