Bugzilla bug #64278: call sched_get_priority_min/max to get the minimum
authorwtc%netscape.com
Wed, 17 Jan 2001 02:42:13 +0000
changeset 1667 172a06dedf4136efabfab57197bb9d7424107d3c
parent 1664 8438fdd496443c808b52578c1d96d06e3a56fea6
child 1669 0cfc605f9f96207f44b109257556ae5c6f843a5c
push idunknown
push userunknown
push dateunknown
bugs64278
Bugzilla bug #64278: call sched_get_priority_min/max to get the minimum and maximum priorities of the default scheduling policy. Thanks to Matt Beauregard <marauder@marauder.tm> for reporting this bug.
pr/src/pthreads/ptthread.c
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -823,22 +823,38 @@ void _PR_InitThreads(
      * pthreads and hence returns a null thread ID if invoked
      * by the primordial thread before any other pthread call.
      * So we explicitly initialize pthreads here.
      */
     pthread_init();
 #endif
 
 #if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
+#if defined(FREEBSD)
+    {
+    pthread_attr_t attr;
+    int policy;
+    /* get the min and max priorities of the default policy */
+    pthread_attr_init(&attr);
+    pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+    pthread_attr_getschedpolicy(&attr, &policy);
+    pt_book.minPrio = sched_get_priority_min(policy);
+    PR_ASSERT(-1 != pt_book.minPrio);
+    pt_book.maxPrio = sched_get_priority_max(policy);
+    PR_ASSERT(-1 != pt_book.maxPrio);
+    pthread_attr_destroy(&attr);
+    }
+#else
     /*
     ** These might be function evaluations
     */
     pt_book.minPrio = PT_PRIO_MIN;
     pt_book.maxPrio = PT_PRIO_MAX;
 #endif
+#endif
     
     PR_ASSERT(NULL == pt_book.ml);
     pt_book.ml = PR_NewLock();
     PR_ASSERT(NULL != pt_book.ml);
     pt_book.cv = PR_NewCondVar(pt_book.ml);
     PR_ASSERT(NULL != pt_book.cv);
     thred = PR_NEWZAP(PRThread);
     PR_ASSERT(NULL != thred);