what is the diff b/w MUTEX and semaphore?
Answers were Sorted based on User's Feedback
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
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|
Answer / krishna
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.)
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|
Answer / manoj
Mutex has ownership while semphore doesnot have the
|Is This Answer Correct ?||7 Yes||7 No|
Answer / ramesh
1.mutex does not have concurrentexecution.
2.semaphore has concurrent execution
|Is This Answer Correct ?||0 Yes||0 No|
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
|Is This Answer Correct ?||1 Yes||2 No|
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
|Is This Answer Correct ?||2 Yes||4 No|
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|
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|
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|
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
|Is This Answer Correct ?||2 Yes||8 No|
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 ?
what is nis server
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?
linux system its not booting up its showing groub error what i need to do?
if root user forget the password how to change it?
how to configure sendmail server on red hat linux version 4 and what and all we Require?
what is mean by raid and what are all raids available even in software and hardware?
what is stored at /lib/modules ?
how to create a ftp user on redhat linux 4.0?
how to configure ftp server on redhat linux?
what is the difference between user APIs and kernel system calls ?
What is the use of proc structure?