What is the difference between mutex and semaphore?

Answer Posted / mickey

Modified question is - What's the difference between A mutex
and a "binary" semaphore in "Linux"?

Ans: Compiled from above correct answers -

Following are the differences –
i) Scope – The scope of mutex is within a process address
space which has created it and is used for synchronization
of threads. Whereas semaphore can be used across process
space and hence it can be used for interprocess synchronization.

ii) Mutex is lightweight and faster than semaphore. Futex is
even faster.

iii) Mutex can be acquired by same thread successfully
multiple times with condition that it should release it same
number of times. Other thread trying to acquire will block.
Whereas in case of semaphore if same process tries to
acquire it again it blocks as it can be acquired only once.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain segmentation with paging?

632


What is the difference between ram and cache memory?

512


List the possible threads a thread can have?

536


What is lxde desktop?

539


What do you understand by the term ‘transistors’?

542






State the advantages of segmented paging over pure segmentation?

645


What is the purpose of an I/O status information?

622


How do I find my hidden files?

547


How much ram do I have?

477


Explain process.

567


What are different tasks of lexical analysis?

569


Why do we need inter process communication?

606


What do you mean by multithreading?

619


Explain Round Robin.

589


How does gcd work?

558