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 get microseconds of system time from Redhat Linux 4.0

2 Answers  


how to create a ftp user on redhat linux 4.0?

6 Answers   Accenture,


what is cups and how to configure?

7 Answers   IBM,


what is the diff b/w MUTEX and semaphore?

12 Answers   Sony, TCS,


what are different ways the context switch happens from user to kernel space or vice-versa ?

0 Answers   Alcatel,






what is nis server

13 Answers  


what is stored in /proc ? what is significance of /proc in linux ?

3 Answers   NetApp,


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

0 Answers   IBM,


How to give the root permision to users?

3 Answers   Wipro,


1.Diff between Active and passive FTP? 2.What is anacron? 3.Diff between yum update and yum install while doing for kernel? 4.root_squash and no_root_squash does what? 5.What are the commands will you execute to find a new hardware? 6.How will you find out a lun allocated from SAN? 7.What is the main diff in CaT5 and CAT6 cable, except the 1/100 and 1/1000? 8.What is stale NFS and How will you fix it? 9.What is kernel panic error? 10.How will you recover password and shadow file, in case both got deleted. Explain the steps? 11.Explain boot process 12.What is network bonding. Explain the steps? 13.What are the exit codes returned by FSCK? 14.What is LDOM? 15.Diff between block and character device?

2 Answers   Wipro,


linux file defaults permition

8 Answers  


if one of the critical section code (linked list) is under ISR & another one in kernel thread ? How you will synchronize for this critical section code ?

4 Answers   NetApp,


Categories