[ffmpeg-devel] question about SDL_LockMutex in ffplay
Andy Parkins
andyparkins
Fri Jul 8 13:35:54 CEST 2005
On Friday 2005 July 08 11:06, zuo bf wrote:
> it too, but shouldn't a mutex can only be locked one time at the same time
> ? With some printf output, i found that every mutex can be locked twice, it
> that the
> correct behaviour ?
I'm going to guess that you tested by doing something like:
printf( "lock first\n" );
lock_mutex();
printf( "unlock first\n" );
unlock_mutex();
then in another thread
printf( "lock second\n" );
lock_mutex();
printf( "unlock second\n" );
unlock_mutex();
And have seen that both "lock first" and "lock second" appear one after the
other. Try again with the printfs inside the locks, like this:
lock_mutex();
printf( "locked first\n" );
// perform some locked work
printf( "unlocking first\n" );
unlock_mutex();
You see it's perfectly acceptable to call lock_mutex() twice from two
different threads, and the second lock will simply wait until the first
thread unlocks again. This is mutex's working exactly as they should.
Hope that helps. I'd be very surprised if you really were getting a mutex
locked twice - it would be a fairly fundamental problem with libpthread.
Andy
--
Dr Andrew Parkins, M Eng (hons), AMIEE
andyparkins at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20050708/a35d45c5/attachment.pgp>
More information about the ffmpeg-devel
mailing list