[SDL] SDLThreads: Locking more than one mutex at once?
bob at pendleton.com
Thu Jul 3 09:29:02 PDT 2003
On Thu, 2003-07-03 at 06:57, Drinkin Park wrote:
> I am currently coding a game for a short project, which I will not bore
> anybody with the details of.
> What I am trying to do, is to write something like this -
> SDL_LockMutex(mutex1); SDL_LockMutex(mutex2);
> so that two mutexes are waited on, and only once both are unlocked, then the
> mutexes are locked again and thread continues
Those statements do not cause your program to wait for both mutices. It
cause you program to wait for muxtex1. Then after mutex1 is locked it
waits for mutex2. It is not possible in SDL to wait for more than one
mutex at a time.
> But I know that this line will not have exactly the desired function, as
> mutex1 may be locked unnecessarily in this instance.
> Is there anything I can do to get the functionality I am after? Any help is
You didn't actually say what your desired functionality is. :-)
I don't see how it can ever be unnecessary to lock both mutices. If each
mutex controls access to a single shared resource, and you have to touch
both resources to perform an operation, then you have to lock both
mutices before you can touch the resources. The mutex is the only way
you have to make sure that you can safely access the resource it
> Hot chart ringtones and polyphonics. Go to
> SDL mailing list
> SDL at libsdl.org
+ Bob Pendleton: independent writer +
+ and programmer. +
+ email: Bob at Pendleton.com +
+ web: www.GameProgrammer.com +
More information about the SDL