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

Differentiate between Multiprocessing, Mutliprogramming and Multithreading.

649


How does the cpu and the ram communicate?

553


What is drawback of mvt?

587


What is memory-management unit (mmu)?

635


When designing the file structure for an operating system, what attributes are considered?

594






How many os can be installed in a pc?

540


Explain demand paging, page fault interrupt, and trashing?

616


What are the advantages of distributed system?

580


Explain the main purpose of an operating system?

611


State two differences between user and kernel space?

525


How long does chkdsk last?

556


How to create a worker thread?

590


Describe Banker’s algorithm

607


On what level of security does windows nt meets?

564


How much ram do I need for 2019 gaming?

490