[Live-devel] Busy waiting on file sources

Åsmund Grammeltvedt asmundg at snap.tv
Fri Jan 5 05:28:52 PST 2007


Hello.

Playing around with the MediaServer, I noticed that cpu usage goes to 100% 
when streaming from files. It appears that after opening a 
ByteStreamFileSource and calling ByteStreamFileSource::doGetNextFrame, 
BasicTaskScheduler will always find that the file socket is ready for reading 
and will trigger the callback ByteStreamFileSource::fileReadableHandler. This 
function in turn concludes that we're not really waiting for any data and 
returns, leading to a new select, a new callback, and so on until the next 
source actually calls ByteStreamFileSource::doGetNextFrame, resetting 
fIsCurrentlyAwaitingData.

This tight busy-waiting loop eats cpu, but doesn't appear to do anything 
useful with it.

Is there any particular reason why fileReadableHandler cannot call 
stopGettingFrames, removing the file socket from the select list until the 
data is actually needed? Applying the attached patch does appear to reduce 
cpu usage significantly, without any nasty side effects. Is this a reasonable 
approach, or am I breaking something?

-- 
Åsmund Grammeltvedt
Snap TV
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bytestreamfilesource_busy_wait.patch
Type: text/x-diff
Size: 514 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20070105/d900485c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20070105/d900485c/attachment-0001.bin 


More information about the live-devel mailing list