[ffmpeg-devel] question about SDL_LockMutex in ffplay
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" );
printf( "unlock first\n" );
then in another thread
printf( "lock second\n" );
printf( "unlock second\n" );
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:
printf( "locked first\n" );
// perform some locked work
printf( "unlocking first\n" );
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.
Dr Andrew Parkins, M Eng (hons), AMIEE
andyparkins at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the ffmpeg-devel