what is the diff b/w MUTEX and semaphore?




Answers were Sorted based on User's Feedback



what is the diff b/w MUTEX and semaphore?..

Answer / ashutosh shashi

Mutex is used for mutual exclusion, only one thread at a
time can use the resourse.
If Mutex is locked by one thread can not unlocked by
another thread.

Semaphore is used when we want one or more thread can use
the resouse at a time.
If Sem object is locked by one thread, it can be unlocked
in other thread.

Is This Answer Correct ?    9 Yes 0 No

what is the diff b/w MUTEX and semaphore?..

Answer / krishna

Mutex:

Is a key to a toilet. One person can have the key - occupy
the toilet - at the time. When finished, the person gives
(frees) the key to the next person in the queue.

Officially: "Mutexes are typically used to serialise access
to a section of re-entrant code that cannot be executed
concurrently by more than one thread. A mutex object only
allows one thread into a controlled section, forcing other
threads which attempt to gain access to that section to wait
until the first thread has exited from that section."
Ref: Symbian Developer Library

(A mutex is really a semaphore with value 1.)

Semaphore:

Is the number of free identical toilet keys. Example, say we
have four toilets with identical locks and keys. The
semaphore count - the count of keys - is set to 4 at
beginning (all four toilets are free), then the count value
is decremented as people are coming in. If all toilets are
full, ie. there are no free keys left, the semaphore count
is 0. Now, when eq. one person leaves the toilet, semaphore
is increased to 1 (one free key), and given to the next
person in the queue.

Officially: "A semaphore restricts the number of
simultaneous users of a shared resource up to a maximum
number. Threads can request access to the resource
(decrementing the semaphore), and can signal that they have
finished using the resource (incrementing the semaphore)."
Ref: Symbian Developer Library

Is This Answer Correct ?    6 Yes 0 No

what is the diff b/w MUTEX and semaphore?..

Answer / manoj

Mutex has ownership while semphore doesnot have the
ownership.

Is This Answer Correct ?    7 Yes 7 No




what is the diff b/w MUTEX and semaphore?..

Answer / ramesh

1.mutex does not have concurrentexecution.
2.semaphore has concurrent execution

Is This Answer Correct ?    0 Yes 0 No

what is the diff b/w MUTEX and semaphore?..

Answer / afsana

mutex is used to run a single thread only so that until the
first thread releases the process other thread has to wait.
But in case of semaphore simultaniously more than on thread
can have access depending upon how many threads we are
allowing.

Is This Answer Correct ?    1 Yes 2 No

what is the diff b/w MUTEX and semaphore?..

Answer / urmi p

basically mutex is a type of semaphore that provides
priority inheritence if a task of lower priority takes the
mutex semaphore and a task of higher priority tries to take
the same semaphore.A simple semaphore does not perform this
task.

Is This Answer Correct ?    2 Yes 4 No

what is the diff b/w MUTEX and semaphore?..

Answer / deepak

* Mutex by default is initialised by 1, where as Semaphore
by default initialised by 0.

* Mutex can be unlocked by that process only which locks it,
where as in Semaphore any process can unlock a locked semaphore.

Is This Answer Correct ?    4 Yes 8 No

what is the diff b/w MUTEX and semaphore?..

Answer / rp

Mutex is a specialized binary semaphore. But the key
difference between semaphore and mutex is:
Mutex can only be given by the task that takes it; but
semaphore can be given by any tasks.

Is This Answer Correct ?    2 Yes 7 No

what is the diff b/w MUTEX and semaphore?..

Answer / kalyani.k

mutex is the name given to the binary semaphore where as
semaphore is general not binary.

Is This Answer Correct ?    6 Yes 12 No

what is the diff b/w MUTEX and semaphore?..

Answer / manohar adari

we have to initialize a semaphore with some value.semaphores
are generally used for resource allocation by initilizing
the semaphore with the available number of resources.

Mutexes are exclusively used for threads and processes
synchronization.

Is This Answer Correct ?    2 Yes 8 No

Post New Answer



More Linux System Calls Interview Questions

What is atomic function / atomic variable ?

1 Answers   Broadcom,


how to create a ftp user on redhat linux 4.0?

6 Answers   Accenture,


I would like to know whether Simado and Setu products are they EPBX or not ?

0 Answers   IBM,


what is the difference between user APIs and kernel system calls ?

1 Answers   NetApp,


linux system its not booting up its showing groub error what i need to do?

4 Answers   Wipro,






What does exec family return?

1 Answers  


How to give the root permision to users?

3 Answers   Wipro,


what is the diff b/w MUTEX and semaphore?

12 Answers   TCS, Sony,


Port number is already in use .. how to fix for apache..?

1 Answers   Google,


What is the use of proc structure?

2 Answers   NetApp,


what is iptabe on redhat linux?

3 Answers   CDAC,


What are system calls used for process management in linux?

0 Answers  






Categories