Bugzilla bug #64278: call sched_get_priority_min/max to get the minimum NSPRPUB_RELEASE_4_1_BRANCH NSPRPUB_RELEASE_4_1_1_BETA
authorwtc%netscape.com
Wed, 17 Jan 2001 02:40:32 +0000
branchNSPRPUB_RELEASE_4_1_BRANCH
changeset 1666 a7c48b1f413edd292a4098a46d20ecf192ddf5b4
parent 1665 98d7f96bec42e25f9ad167b8b2eb60e0e71bffc1
child 1692 6b448df85f32ff0215aa8dbd79aa0a8742934ae5
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. (NSPRPUB_RELEASE_4_1_BRANCH)
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);