Strange. I made a few minor changes (see attached patch) and when I run your code on my test machine running Linux kernel 2.6.35 I get the following output:
$ sudo ./latencytest ./latencytest starting... My original scheduling policy is SCHED_OTHER (0) The original minimum scheduling priority is 0, the maximum is 0 sched_get_priority_max(1) returned 99 sched_get_priority_min(1) returned 1 My target scheduling policy is SCHED_FIFO (1) The target minimum scheduling priority is 1, the maximum is 99 params.sched_priority now set to 98 It worked - now running in high-priority mode params.sched_priority now set to 98 Now running at original scheduler policy My scheduling policy is SCHED_OTHER The minimum scheduling priority is 0, the maximum is 0 $ We'll have to look deeper. Of course, the first thing that comes to mind is that you are running a 3.x kernel, and I am not (yet). Regards, --kevin -- alumni.unh.edu!kdc / http://kdc-blog.blogspot.com/ GnuPG: D87F DAD6 0291 289C EB1E 781C 9BF8 A7D8 B280 F24E And the Army Ants, they leave nothin' but the bones... -- Tom Waits
--- latencytest.c.orig 2012-11-08 17:27:56.868748156 -0500 +++ latencytest.c 2012-11-08 17:21:19.941866904 -0500 @@ -43,7 +43,8 @@ return buf; } -main(int argc, char ** argv) { + +int main(int argc, char ** argv) { int origpolicy; /* Current process' scheduling priority */ int origPolicyMaxPriority; /* Maximum priority for the original @@ -71,7 +72,7 @@ strerror(errno)); }; if ((origPolicyMinPriority = sched_get_priority_min(origpolicy)) < 0) { - fprintf(stderr, "sched_get_priority_min(%d) failed", origpolicy, + fprintf(stderr, "sched_get_priority_min(%d) failed: %s", origpolicy, strerror(errno)); }; printf("My original scheduling policy is %s\n", PolicyToStr(origpolicy)); @@ -140,6 +141,7 @@ /* ... */ /* Return to normal priority. */ + params.sched_priority = 0; /* assumes orig schedule was SCHED_OTHER */ retval = sched_setscheduler (pid, origpolicy, ¶ms); if (retval < 0) { fprintf(stderr, "sched_setscheduler (%d, %d, ...) failed: %s\nQuiting.\n", @@ -181,11 +183,13 @@ strerror(errno)); }; if ((origPolicyMinPriority = sched_get_priority_min(origpolicy)) < 0) { - fprintf(stderr, "sched_get_priority_min(%d) failed", origpolicy, + fprintf(stderr, "sched_get_priority_min(%d) failed: %s", origpolicy, strerror(errno)); }; printf ("The minimum scheduling priority is %d, the maximum is %d\n", origPolicyMinPriority, origPolicyMaxPriority); + + return EXIT_SUCCESS; } /**
_______________________________________________ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/