POSIX’s mutex is equivalent to Win32’s CRITICAL_SECTION — its scope is limited to a single process. Win32’s mutex (Actually called a “mutant” in NT land) serves as a cross process locking mechanism. What is pthreads’ equivalent for cross-process locks?
POSIX’s mutex is equivalent to Win32’s CRITICAL_SECTION — its scope is limited to a
Share
It’s a pthread_mutex_t with a pshared attribute set to PTHREAD_PROCESS_SHARED . However, you’re responsible to place such a mutex in shared memory, that all processes can access – so it’s not as simple as the win32 api.
Perhaps closer to win32 is a posix or sysv semaphore. Traditionally, synchronization across processes has also been done using file locks e.g. flock or lockf (this is in no way as slow as it might sound)