OSSP CVS Repository

ossp - Check-in [4738]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4738
Date: 2004-Oct-08 18:17:02 (local)
2004-Oct-08 16:17:02 (UTC)
User:rse
Branch:
Comment: Added PTH_CTRL_FAVOURNEW control which allows the user to disable the favouring of new threads on scheduling to get more strict priority based scheduling behavior.

Triggered by: Vinu V <Vinu_V@mindtree.com>

Tickets:
Inspections:
Files:
ossp-pkg/pth/ChangeLog      1.625 -> 1.626     5 inserted, 0 deleted
ossp-pkg/pth/THANKS      1.96 -> 1.97     1 inserted, 0 deleted
ossp-pkg/pth/pth.h.in      1.142 -> 1.143     1 inserted, 0 deleted
ossp-pkg/pth/pth.pod      1.163 -> 1.164     9 inserted, 0 deleted
ossp-pkg/pth/pth_lib.c      1.57 -> 1.58     4 inserted, 0 deleted
ossp-pkg/pth/pth_sched.c      1.91 -> 1.92     10 inserted, 3 deleted

ossp-pkg/pth/ChangeLog 1.625 -> 1.626

--- ChangeLog    2004/09/25 21:14:44     1.625
+++ ChangeLog    2004/10/08 16:17:02     1.626
@@ -21,6 +21,11 @@
                   
   Changes between 2.0.2 and 2.0.3 (12-Sep-2004 to xx-xxx-2004)
 
+   *) Added PTH_CTRL_FAVOURNEW control which allows the user
+      to disable the favouring of new threads on scheduling
+      to get more strict priority based scheduling behavior.
+      [Ralf S. Engelschall, Vinu V <Vinu_V@mindtree.com>]
+
    *) Upgraded build environment to GNU libtool 1.5.10
       [Ralf S. Engelschall]
 


ossp-pkg/pth/THANKS 1.96 -> 1.97

--- THANKS       2004/09/12 11:45:09     1.96
+++ THANKS       2004/10/08 16:17:02     1.97
@@ -107,6 +107,7 @@
     o  David Scott Urban           <urban@ast.lmco.com>
     o  Laurent Vaucher             <laurent.vaucher@ficsgrp.com>
     o  Martin Vernard              <vernard@cc.gatech.edu>
+    o  Vinu V                      <Vinu_V@mindtree.com>
     o  Olaf Wasmuth                <olaf.wasmuth@europe.eds.com>
     o  Chia-Hsing Yu               <davidyu@oio.cx>
 


ossp-pkg/pth/pth.h.in 1.142 -> 1.143

--- pth.h.in     2004/09/12 11:36:13     1.142
+++ pth.h.in     2004/10/08 16:17:02     1.143
@@ -124,6 +124,7 @@
                                        PTH_CTRL_GETTHREADS_SUSPENDED|\
                                        PTH_CTRL_GETTHREADS_DEAD)
 #define PTH_CTRL_DUMPSTATE            _BIT(10)
+#define PTH_CTRL_FAVOURNEW            _BIT(11)
 
     /* the time value structure */
 typedef struct timeval pth_time_t;


ossp-pkg/pth/pth.pod 1.163 -> 1.164

--- pth.pod      2004/07/13 10:50:49     1.163
+++ pth.pod      2004/10/08 16:17:02     1.164
@@ -679,6 +679,15 @@
 of the internal B<Pth> library state is written to. The main information
 which is currently written out is the current state of the thread pool.
 
+=item C<PTH_CTRL_FAVOURNEW>
+
+This requires a second argument of type `C<int>' which specified whether
+the B<GNU Pth> scheduler favours new threads on startup, i.e., whether
+they are moved from the new queue to the top (argument is C<TRUE>) or
+middle (argument is C<FALSE>) of the ready queue. The default is to
+favour new threads to make sure they do not starve already at startup,
+although this slightly violates the strict priority based scheduling.
+
 =back
 
 The function returns C<-1> on error.


ossp-pkg/pth/pth_lib.c 1.57 -> 1.58

--- pth_lib.c    2004/07/13 10:50:49     1.57
+++ pth_lib.c    2004/10/08 16:17:02     1.58
@@ -193,6 +193,10 @@
         FILE *fp = va_arg(ap, FILE *);
         pth_dumpstate(fp);
     }
+    else if (query & PTH_CTRL_FAVOURNEW) {
+        int favournew = va_arg(ap, int);
+        pth_favournew = (favournew ? 1 : 0);
+    }
     else
         rc = -1;
     va_end(ap);


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