Monitor as synchronization on Windows

自作多情 提交于 2019-12-10 00:35:15

问题


Is there any implementation of monitor on Windows? I didn't see any win32 API references Monitor.


回答1:


Windows does not have a monitor implementation of its own. However, Vista introduced Condition Variables and Slim Reader/Writer locks, which can be used together to create a monitor implementation.




回答2:


Yes it does. Windows has monitors and monitor functions: EnterCriticalSection is similar to POSIX pthread_mutex_lock (enters the monitor). LeaveCriticalSection is similar to POSIX pthread_mutex_unlock (leaves monitor).

SleepConditionVariableCS similar to POSIX pthread_cond_wait.

WakeConditionVariable ... POSIX pthread_cond_signal.

WakeAllConditionVariable ... POSIX pthread_cond_broadcast

All these funcions you can find here:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686360(v=vs.85).aspx



来源:https://stackoverflow.com/questions/26836224/monitor-as-synchronization-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!