OSSP CVS Repository

ossp - Difference in ossp-pkg/pth/pth_sched.c versions 1.91 and 1.92
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/pth/pth_sched.c 1.91 -> 1.92

--- pth_sched.c  2004/07/13 10:50:49     1.91
+++ pth_sched.c  2004/10/08 16:17:02     1.92
@@ -35,6 +35,7 @@
 intern pth_pqueue_t pth_WQ;         /* queue of threads waiting for an event */
 intern pth_pqueue_t pth_SQ;         /* queue of suspended threads            */
 intern pth_pqueue_t pth_DQ;         /* queue of terminated threads           */
+intern int          pth_favournew;  /* favour new threads on startup         */
 intern float        pth_loadval;    /* average scheduler load value          */
 
 static int          pth_sigpipe[2]; /* internal signal occurrence pipe       */
@@ -68,6 +69,9 @@
     pth_pqueue_init(&pth_SQ);
     pth_pqueue_init(&pth_DQ);
 
+    /* initialize scheduling hints */
+    pth_favournew = 1; /* the default is the original behaviour */
+
     /* initialize load support */
     pth_loadval = 1.0;
     pth_time_set(&pth_loadticknext, PTH_TIME_NOW);
@@ -179,13 +183,16 @@
      */
     for (;;) {
         /*
-         * Move threads from new queue to ready queue and give
-         * them maximum priority so they start immediately
+         * Move threads from new queue to ready queue and optionally
+         * give them maximum priority so they start immediately.
          */
         while ((t = pth_pqueue_tail(&pth_NQ)) != NULL) {
             pth_pqueue_delete(&pth_NQ, t);
             t->state = PTH_STATE_READY;
-            pth_pqueue_insert(&pth_RQ, pth_pqueue_favorite_prio(&pth_RQ), t);
+            if (pth_favournew)
+                pth_pqueue_insert(&pth_RQ, pth_pqueue_favorite_prio(&pth_RQ), t);
+            else
+                pth_pqueue_insert(&pth_RQ, PTH_PRIO_STD, t);
             pth_debug2("pth_scheduler: new thread \"%s\" moved to top of ready queue", t->name);
         }
 

CVSTrac 2.0.1