site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1248998040; bh=NuV6pWRDf3cvZ14QV3bA1v+zyB0jvoAcHZEYkj4MIUM=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=nij/nMeBllIZEebQmdW6OxTOI/ZRuNmJe1Qn6SbFXoB4C+XJmXQHCQYSl3t7PfcCix1XnjM09LQwH/vf4IF1pQktEFAX5RRoVouadlr+fdRwWfv+7rehbrI7Px26fQtz2H9X/iIB+5XpwTuOmGs2hhFeFkWa6ljnM/rVv4RR4AQ= Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=lsmU43HKAhTRqKYqokC+wxlHDp/4hWkylqrz/F07tbu3b+8mleJ/zoy9YyCA6nxzl9IjS/bS0026tIhuRSzknh8UqbYfrXtos+/tAjRHIlCa0VGh2/4Y2aBrJ8xD+Y7nrDY/0apzlksWcMqIhSl/4kJh9xPG+hBxttNhYX0VMHE=; Hi! --- On Thu, 7/30/09, Terry Lambert <tlambert@apple.com> wrote:
You should probably read:
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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Mike Mimic