site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -- Terry Hi! So, any suggestions? Is then this a bug in the scheduler? Mike --- On Fri, 7/31/09, Mike Mimic <ppagee@yahoo.com> wrote: From: Mike Mimic <ppagee@yahoo.com> Subject: Re: Idle priority To: "Terry Lambert" <tlambert@apple.com> Cc: "darwin-kernel@lists.apple.com" <darwin-kernel@lists.apple.com> Date: Friday, July 31, 2009, 1:54 AM Hi! --- On Thu, 7/30/09, Terry Lambert <tlambert@apple.com> wrote: You should probably read: Thanks. I have read it and improved my test program, "nice": #include <mach/mach.h> #include <mach/thread_policy.h> #include <stdio.h> int set_idle() { struct thread_precedence_policy policy; policy.importance = 0; // IDLE_PRI return thread_policy_set(mach_thread_self(), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&policy, THREAD_PRECEDENCE_POLICY_COUNT) == KERN_SUCCESS; } int main(int argc, char *argv[]) { if (!set_idle()) { fprintf(stderr, "set_idle() failed\n"); return 1; } int j; for (j = 0; ; j++) { printf("%d\n", j); // Busy wait int i; for (i = 0; i < 100000000; i++); } return 0; } In documentation it is written about the importance value: While this is a signed 32-bit value, the minimum legal value is zero (IDLE_PRI). threads set to IDLE_PRI will only execute when no other thread is scheduled to execute. Measurements are as follows. In the first case I got such values: - user time - mean: 10.0282 - standard deviation: 0.0008 - real time - mean: 10.0939 - standard deviation: 0.1165 In the seconds case I got such values: - user time - mean: 10.0285 - standard deviation: 0.0005 - real time - mean: 20.0722 - standard deviation: 0.1155 There is even bigger difference. Am I doing something wrong? _______________________________________________ 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... If you think there is a bug there, then you need to file a bug and attach your code examples so that the engineers who work on the scheduler can decide whether or not it's a problem of implementation or of perception. I will point out that the reported real time on the second one is very close to 20.0722, double the CPU time, which implied that it didn't actually get any CPU time until the competing (non-idle priority) process finished, which is what you were appeared to be asking to have happen. However, you can't take the "top" or "time" numbers literally, since they operate on digested resource usage information obtained after the child exits before it is reaped, using BSD rusage() calls. To get actual time-on-cpu on a per-process basis you'd need to examine the thread state structure before the thread exits. This is why I suggested you use shark to gather the information, back when this thread started. On Aug 4, 2009, at 2:39 PM, Mike Mimic wrote: <http://developer.apple.com/documentation/Darwin/Conceptual/KernelProgramming...
which documents the Mach scheduler interfaces. Mike This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert