Re: Idle priority
Re: Idle priority
- Subject: Re: Idle priority
- From: Mike Mimic <email@hidden>
- Date: Thu, 30 Jul 2009 16:54:00 -0700 (PDT)
Hi!
--- On Thu, 7/30/09, Terry Lambert <email@hidden> wrote:
> You should probably read:
>
> <http://developer.apple.com/documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html>
>
> which documents the Mach scheduler interfaces.
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?
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