Ravi, this is semaphore, not a mutex. See, there are lot of differences in
mutex and semaphores.
Even the threads of a single process cannot have access to each  other's
mutex.
Mutexes can be applied only to threads in a single process and do not  work
between processes as do semaphores(as used in this example).

thread/process which acquires a lock on mutex , is the only one to unlock it
..
Mutexes can be made to work between processes (it's an implementation
detail). But the *concept* of a mutex is Owner + (Lock & Key) pair. By
adding the concept of Owner to a lock, we can ensure that only the person
who locked the lock can open it. This *guarantees* mutual exclusion (which
is unlike a semaphore). A semaphore is a signalling mechanism between
threads/processes that simply indicates an event that has occured
asynchronously to the process/thread's flow of control (for
processes/threads other than the event generating process of-course). It is
often used to indicate that cooperative progress may be possible on
resources under contention or synchronization between states may be
required. Any cooperating process/thread can modify the value of a semaphore
which is not true of a mutex.

Note: Mutex and Semaphore are essentially concepts. Their implementations
can vary in different systems and have different implementation constraints
but the theory is clear. The two are different and serve different purposes
though they may share implementation details.

unlike semaphores mutex does not have any list(of waiting processes)
associated  with it and just is a kind of lock and key model with no waiting




THERE IS ONE THREAD WITH SUBJECT : MUTEX
You cna search that for more clarity..

Thanks and Regards
Saurabh Agrawal

On Sat, Sep 10, 2011 at 10:52 AM, ravi maggon <maggonr...@gmail.com> wrote:

> tell the out of the below code related to mutex and semaphore
>
> process1
> wait(mutex);
> print 0
> print 1
> signal(mutex);
>
>
> process2
>
> wait(mutex)
> print 1
> print 0
> signal(mutex)
>
> --
>
> Regards
> Ravi Maggon
> Final Year, B.E. CSE
> Thapar University
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to