The latest CVS snapshot has support for semaphores and condition variables:
Please test this code as thoroughly as you can. I haven’t updated the
VC++ projects yet to include the new files, but other platforms should
The condition variable implementation is written on top of semaphores,
and I don’t have any code to thoroughly exercise it, so if you have any,
please let me know!
From the WhatsNew file:
Added condition variable support, based on mutexes and semaphores
if native condition variables are not available.
The new function prototypes are in SDL_mutex.h
Added semaphore support, based on mutexes and condition variables if native semaphores are not available. SDL_CreateSemaphore() SDL_DestroySemaphore() SDL_SemWait() SDL_SemTryWait() SDL_SemWaitTimeout() SDL_SemPost() SDL_SemValue() The new function prototypes are in SDL_mutex.h
Mutexes are now recursive, meaning you can do the following:
SDL_LockMutex(lock); <-- recursive lock, doesn’t deadlock
SDL_UnlockMutex(lock); <-- lock is released
This may go away, as it introduces a bit of overhead in checking lock
ownership. I’m curious if people want to keep them or not?
-Sam Lantinga, Lead Programmer, Loki Entertainment Software