Semaphore vs mutex in os environment

Status
Not open for further replies.

chandu.kurapati

Full Member level 3
Joined
Oct 31, 2013
Messages
186
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Location
Bengaluru, India
Activity points
2,778
Semaphore vs mutex in os enviorlment

Hi,
I'm beginner to the linux environment trying to understand the internals, now looking in to semaphore and mutex concept.

I understood the mutex and semaphore, but in real programming world in which scenario we will go for semaphore & in which scenario we will go for mutex.

can you please elaborate about semaphore & mutex.

Thanks & Regards,
Chandu.Kurapati.
 

Re: Semaphore vs mutex in os enviorlment

Hi there,

A mutex really stands for mutual-exclusion. It surrounds a ressource so that it's locked before and released after. Also, the OS is aware of that, so it puts threads/processes waiting for it sleep and wakes them when they're released.

A semaphore is more like a barrier to me. It's a synchronization mecanism. It's a way for a thread/process to wait for a condition, before it enters a code segment

Hope it helps.
Laurent
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…