Re: Yielding the processor in a kext?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com On Sep 7, 2007, at 10:22 AM, Régis Duchesne wrote: The problem here is that you are conflating "thread" with "work". 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. 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 :) = Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... 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. 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. 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Smith