Re: More thread scheduling observations
Re: More thread scheduling observations
- Subject: Re: More thread scheduling observations
- From: Kurt Revis <email@hidden>
- Date: Sun, 5 May 2002 05:32:42 -0700
On Saturday, May 4, 2002, at 11:40 PM, Ian Ollmann wrote:
Why dont you give this a try: Turn timesharing off so that you are
scheduled in a round robin fashion, among threads of equal priority. If
you set your priority equal to the window server, you should get the CPU
as often as the window server does.
This works quite well, thanks! Turning importance up to 64 helped a
lot, but I could still get dropouts. Turning off timeshare as well makes
it really reliable--I can't get dropouts at all, even when the buffer
between my feeder thread and the audio IO thread is quite small. And it
still seems to work OK under more ordinary heavy load.
Here's the code for those playing along at home (it's pretty simple):
{
kern_return_t error;
thread_extended_policy_data_t extendedPolicy;
thread_precedence_policy_data_t precedencePolicy;
extendedPolicy.timeshare = 0;
error = thread_policy_set(mach_thread_self(),
THREAD_EXTENDED_POLICY, (thread_policy_t)&extendedPolicy,
THREAD_EXTENDED_POLICY_COUNT);
if (error != KERN_SUCCESS) {
#if DEBUG
mach_error("Couldn't set feeder thread's extended policy",
error);
#endif
}
precedencePolicy.importance = 64;
error = thread_policy_set(mach_thread_self(),
THREAD_PRECEDENCE_POLICY, (thread_policy_t)&precedencePolicy,
THREAD_PRECEDENCE_POLICY_COUNT);
if (error != KERN_SUCCESS) {
#if DEBUG
mach_error("Couldn't set feeder thread's precedence policy",
error);
#endif
}
}
http://developer.apple.com/techpubs/macosx/Darwin/General/KernelProgramming/
scheduler/Using_Mach__pplications.html
I looked at this a while back, but didn't read it in depth because I
wasn't doing any kernel programming. Should have paid more attention,
since there is some info in there which is useful for user level
programs.
--
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.