From: Michael W. <mfwitten@MIT.EDU> - 2008-07-10 06:38:23
|
Hello, Apparently sched_setscheduler() isn't quite fully supported, and it certainly isn't defined in Mac OS X 10.5.3. Following this: http://lists.apple.com/archives/Unix-porting/2005/Jul/msg00027.html I have attached a patch that better handles the case in which priority scheduling is not implemented (use the attached file, because my MTA seems to remove empty lines, thereby corrupting the patch; I should also note that I haven't really thought about the consequences of my changes, though it should just be rearrangement with a slight compile-time optimization due to the use of preprocessor conditionals): --- encodedv/dvconnect.c.old 2008-07-10 02:27:10.000000000 -0400 +++ encodedv/dvconnect.c 2008-07-10 02:26:38.000000000 -0400 @@ -857,24 +857,19 @@ int rt_raisepri (int pri) { -#ifdef _SC_PRIORITY_SCHEDULING +#if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param scp; - /* - * Verify that scheduling is available - */ - if (sysconf (_SC_PRIORITY_SCHEDULING) == -1) { - fprintf (stderr, "WARNING: RR-scheduler not available, " - "disabling.\n"); - return (-1); - } else { - memset (&scp, '\0', sizeof (scp)); - scp.sched_priority = sched_get_priority_max (SCHED_RR) - pri; - if (sched_setscheduler (0, SCHED_RR, &scp) < 0) { - fprintf (stderr, "WARNING: Cannot set RR-scheduler\n"); - return (-1); - } - } + memset (&scp, '\0', sizeof (scp)); + scp.sched_priority = sched_get_priority_max (SCHED_RR) - pri; + if (sched_setscheduler (0, SCHED_RR, &scp) < 0) { + fprintf (stderr, "WARNING: Cannot set RR-scheduler, disabling \n"); + return (-1); + } + +#else + fprintf (stderr, "WARNING: RR-scheduler not available, disabling. \n"); + return (-1); #endif return (0); } Sincerely, Michael Witten |