[FFmpeg-devel] [PATCH] lazily create threads in pthread.c

Alexander Strange astrange
Sun Aug 12 20:33:31 CEST 2007

On Aug 12, 2007, at 2:04 PM, Reimar D?ffinger wrote:

> Hello,
> On Sun, Aug 12, 2007 at 01:47:25PM -0400, Alexander Strange wrote:
>> This patch changes pthread.c so that threads aren't created until  
>> execute()
>> requests them.
>> This way, you can unconditionally call avcodec_thread_init() and  
>> not have
>> unused threads lying around if they aren't used.
> You forgot to say what the advantage is supposed to be...
>> It could also save one worker thread by reusing the main thread,  
>> instead of
>> sleeping it; I'll probably look at that later.
> Again, advantage? I think any halfway recent OS is designed to easily
> handle hundreds of threads, I can't imagine ffmpeg using e.g. 4  
> instead of 5
> threads will gain much if anything.

Pretty much cosmetic. A few more sleeping threads won't confuse any  
decent OS,
they just clutter up gdb or profilers. And ps output, for those  
pthread systems that fork for every thread.

I don't see any stability or performance changes introduced by this,  
so it should be harmless otherwise.

More information about the ffmpeg-devel mailing list