Re: CLI producer code cycle starvation
Re: CLI producer code cycle starvation
- Subject: Re: CLI producer code cycle starvation
- From: Kurt Revis <email@hidden>
- Date: Thu, 20 Jun 2002 08:10:08 -0700
When I run the audio player from the command line, leaving the rest of
the system quiescent, the audio file plays to completion. But if I grab
a window on the screen with the mouse, and wave the window about
vigorously,
the IOProc empties the ring buffer before the decompressor gets
scheduled
again, based on diagnostic printout of buffer indices and the like.
I've been through the same thing recently. Check the archives for the
thread with subject "More thread scheduling observations", around May
5th.
The basic idea is that you want to increase the priority of your feeder
thread a little bit, and set it to not be scheduled using the timeshare
policy (so its priority will not be adjusted dynamically).
Here is some code which implements this:
http://www.snoize.com/Code/PlayBufferedSoundFile.tar.gz
See QTSoundFilePlayer.m, especially the -setThreadPolicy method.
Also, my understanding is that the window-dragging thing is considered a
bug, which will supposedly be fixed in Jaguar.
c) just for my curiousity, why is the scheduler (almost) *never*
scheduling
the producer process? Is it because the program itself is scheduled
every
time there's a call to the audio IOProc, and so by the scheduler's
lights,
the player is getting its share of cycles?
It isn't getting any time because the window server (which is what
handles the window drag) is running with a very high priority, and is
starving out other timeshare threads. Non-timeshare threads (like your
audio IO threads) still get a chance to run, though.
As I understand it, the scheduler mostly treats threads as independent
entities, regardless of what task they belong to. So the scheduler won't
deny a thread some time just because it recently gave another thread in
that task some time. (This is undoubtedly an oversimplification,
though...)
Hope this helps.
--
Kurt Revis
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.