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

how to configure ftp server on redhat linux?

9 Answers   Infosys,


What is atomic function / atomic variable ?

1 Answers   Broadcom,


How to get microseconds of system time from Redhat Linux 4.0

2 Answers  


how to create samba server in fedora linux 9 ?

2 Answers   Accenture,


What is the Diffrent between Redhat linux And suse linux

2 Answers   Wipro,






what kind of information the linux driver modules (.ko ) files has ?

2 Answers   NetApp,


what is nis server

13 Answers  


what is the diff b/w MUTEX and semaphore?

12 Answers   Sony, TCS,


What will happen when we invoke a system call and say with an example of invoking a system call ?read? for a device?

3 Answers   NetApp,


why the kernel panic error was appering?

13 Answers   Air2Web, Allianz,


What is the use of proc structure?

2 Answers   NetApp,


what are Softirq's and how many major numbers be allocated in the linux kernel(2.4) ?

1 Answers  


Categories