Hi,
currently SDL has MUTEX and semaphores for thread synchronisation.
Is it possible to have something equal to:
pthread_cond_wait
pthread_cond_signal
and pthread_try_lock ?
You need these things when you protect a thread with a mutex variable.
(normally you protect a single variable with a mutex, and not a
thread)
example:
Thread 1 runs (holds mutex A locked)
Thread 2 locks mutex B
Thread 1 polls mutex B with a try_lock (gets EBUSY)
Thread 1 release Mutex A and goes to sleep on a condition variable.
Thread 2 change a variable (he holds Mutex A and B)
Thread 2 release Mutex B
Thread 2 signals a wakeup Condition
Thread 1 graps Mutex A back and runs.
You need the trylock because this is the condition for a thread to
"sleep"
and wait for a condition. You cant do it with a real lock, because this
is
then a deadlock, you need the trylock.
Is it possible to make a workaround with semaphores?
Martin