Re: Yielding the processor in a kext?
Re: Yielding the processor in a kext?
- Subject: Re: Yielding the processor in a kext?
- From: Michael Smith <email@hidden>
- Date: Fri, 7 Sep 2007 13:56:42 -0700
On Sep 7, 2007, at 10:22 AM, Régis Duchesne wrote:
The problem here is that you are conflating "thread" with "work".
Ideally you would parcel your work out in well-ordered units, and
schedule those units to threads in such a fashion that progress
happens
with the desired balance.
That is great in an ideal world where you write the code that the
threads execute. But we don't live in an ideal world: in my case each
thread is like a black box: I control the initial input to these
threads, but then they go do their heavy computation, and just report
progress.
So use one of the several techniques I proposed that take advantage of
the fact that you know what the threads are doing, and you have the
ability to block them for arbitrary periods. I even gave you
pseudocode for the task.
We are wondering which API can be used to do that. Would an
IOSleep(0)
(which is the way you do it on Windows) work or will it just be
ignored?
You don't want to do this, on either platform. You have no control
over
what "slow it down" actually means, and you aren't communicating what
you really want to the scheduler.
I have perfect control on Windows where Sleep(0) is documented to do
exactly what I want. I have perfect control on Linux where
cond_resched() is documented to do exactly what I want. I'm trying to
have perfect control on Mac OS by finding an API that is documented to
do exactly what I want :)
Your assumption is predicated on a number of things that you consider
invariant (scheduler behaviour not the least of them) which aren't.
The deterministic approach I detailed in the message you quote above
will give you more consistent results, and it will work on all of the
platforms you name.
= Mike _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden