Index: ossp-pkg/pth/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/pth/ChangeLog,v rcsdiff -q -kk '-r1.625' '-r1.626' -u '/v/ossp/cvs/ossp-pkg/pth/ChangeLog,v' 2>/dev/null --- 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 ] + *) Upgraded build environment to GNU libtool 1.5.10 [Ralf S. Engelschall] Index: ossp-pkg/pth/THANKS RCS File: /v/ossp/cvs/ossp-pkg/pth/THANKS,v rcsdiff -q -kk '-r1.96' '-r1.97' -u '/v/ossp/cvs/ossp-pkg/pth/THANKS,v' 2>/dev/null --- 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 o Laurent Vaucher o Martin Vernard + o Vinu V o Olaf Wasmuth o Chia-Hsing Yu Index: ossp-pkg/pth/pth.h.in RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.h.in,v rcsdiff -q -kk '-r1.142' '-r1.143' -u '/v/ossp/cvs/ossp-pkg/pth/pth.h.in,v' 2>/dev/null --- 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; Index: ossp-pkg/pth/pth.pod RCS File: /v/ossp/cvs/ossp-pkg/pth/pth.pod,v rcsdiff -q -kk '-r1.163' '-r1.164' -u '/v/ossp/cvs/ossp-pkg/pth/pth.pod,v' 2>/dev/null --- 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 library state is written to. The main information which is currently written out is the current state of the thread pool. +=item C + +This requires a second argument of type `C' which specified whether +the B scheduler favours new threads on startup, i.e., whether +they are moved from the new queue to the top (argument is C) or +middle (argument is C) 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. Index: ossp-pkg/pth/pth_lib.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_lib.c,v rcsdiff -q -kk '-r1.57' '-r1.58' -u '/v/ossp/cvs/ossp-pkg/pth/pth_lib.c,v' 2>/dev/null --- 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); Index: ossp-pkg/pth/pth_sched.c RCS File: /v/ossp/cvs/ossp-pkg/pth/pth_sched.c,v rcsdiff -q -kk '-r1.91' '-r1.92' -u '/v/ossp/cvs/ossp-pkg/pth/pth_sched.c,v' 2>/dev/null --- 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); }