Hi,
can someone explain me the difference between mutex and semaphores?
Thanks
Hi,
can someone explain me the difference between mutex and semaphores?
Thanks
They are the same data type, and both work as locks or in-memory flags to control access to some object like shared memory or protected code segments.
semaphores may have values 0 -> n where n is an arbitrary number, like 10, or 4.
A mutex has two values either set = 1 or not set = 0. mutexes are typically acted upon by special functions, particularly in the pthreads library.
Local event flags are the most common example of sempahore use. Mutexes are used extensively in threads programming, for example.