Click here to Skip to main content
15,904,297 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Mutex will allow to access the across the process means in different process?
If Yes please provide some realtime example.

Regards
Ranjith
Posted

1 solution

No, a mutex will prevent different process to screw up access, through synchronization.

Yes, a mutex can be shared by two or more threads of different processes, not only the threads of the same process.

If a mutex is used by threads of the same processes, it does not have to be named, but different processes requires the name. This is because all processes are well isolated; and the memory locations, such as pointers to an object like a mutex may have formally identical address in each memory space but point to different physical location. This way, without a name, it would be impossible to share any object. So, each process gets its own pointer to a mutex, which physically should be one shared object.

Please see:
http://en.wikipedia.org/wiki/Mutex[^],
http://msdn.microsoft.com/en-us/library/tt45160e%28v=vs.80%29.aspx[^].

—SA
 
Share this answer
 
v2
Comments
ranjithkumar81 28-Dec-12 2:43am    
the Mutex object allows synchronizing objects across the process.

http://www.codeproject.com/Articles/7953/Thread-Synchronization-for-Beginners
Sergey Alexandrovich Kryukov 28-Dec-12 2:49am    
Of course it does. Why are you showing this reference at all? I already explained what it does. Did you get it, or have some questions?
—SA
ranjithkumar81 28-Dec-12 3:04am    
Could you provide some realtime example in Mutex and Criticalsection.
Sergey Alexandrovich Kryukov 28-Dec-12 3:22am    
Realtime? Do you know what is "real time"? :-)
It's too late in my time zone. Please remind me later...
But the samples are elementary. They all look like

M.Get
Do something inside critical block
M.Release

You will find million samples. It's more important to understand how a thread work. Putting a code sample here is not very effective. You could better try it by yourself using API literally, and running it under debugger...
—SA
ranjithkumar81 28-Dec-12 4:51am    
Thanks man...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900