File Exchange

image thumbnail


version (4.44 KB) by Joshua Dillon
This mex file provides an interface with the POSIX semaphore functionality.


Updated 10 Aug 2011

View License

This mex file provides an interface with the POSIX semaphore functionality. For more information, see `man 7posix semaphore.h`.

To install/compile: mex semaphore.c

Cite As

Joshua Dillon (2021). semaphore (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Darwin Te

Jonathan C. Lansey

Andrew Smart

K, this one will work with MS Visual Studio (and POSIX compliant platforms):

You can alternatively try to use a POSIX implementation on top of windows:

Andrew Smart

Unfortunately pastebin is now blocked at my work :(
I've submitted a new semaphore package on the file exchange, it will appear as soon as it is approved.

Andrew Smart

I apologize about that. It appears I had misused pastebin. Looks like that microsoft API link is dead too. I had augmented Mr. Dillon's code to use CreateSemaphore, OpenSemaphore, and ReleaseSemaphore from the Windows API instead of sem_init, sem_wait, and etc from POSIX. Will attach a patch shortly.

Omar Shenawy

@Andrew Smart:
The pastebin link is private, if you could please post another link?

Andrew Smart

Thank you very much Mr Dillon. Didn't work for me w/ MS Visual Studio compiler, so I added support using whatever this is ( a year or so ago:

Hope this helps someone out there.


MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: sharedmatrix

Inspired: Semaphore, semaphore_POSIX_and_Windows

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!