开发者

How does CreateMutex() internally work?

开发者 https://www.devze.com 2022-12-16 20:11 出处:网络
Basically, it is used to make an application instance singleton. I wish to 开发者_Go百科know, how it works internally and how does OS manage it ?It creates a system-wide object. How the OS manages it

Basically, it is used to make an application instance singleton.

I wish to 开发者_Go百科know, how it works internally and how does OS manage it ?


It creates a system-wide object. How the OS manages it is a consealed implementation detail, you can only use the mutex trough the OS-supplied functions (like ReleaseMutex() for example).


This MSDN Article has some information about the underlying details of mutexes. In general, a mutex created with the Windows CreateMutex function is a kernel-owned object, which means that a user level application must transition from user mode to kernel mode to acquire ownership of the mutex.


This gives a few hints about internals

http://msdn.microsoft.com/en-us/library/ms684266%28VS.85%29.aspx

If you are interested in algorithms wikipedia is a good starting point. If you are interested in implementation, google linux source code semaphore.c

0

精彩评论

暂无评论...
验证码 换一张
取 消