On Fri, 21 Dec 2001, Luigi Rizzo wrote: > Don't know how interesting this can be, but i am writing > (no plans to commit it, unless people find it interesting) > some code to implement a weight-based instead of priority-based > scheduler. The code is basically the WF2Q+ scheme which is > already part of dummynet, adapted to processes. > It is quite compact, and i think i can make it reasonably > compatible with the old scheme, i.e. a sysctl var can be > used to switch between one and the other with reasonably > little overhead. > > This would help removing the ugly property that priority-based > have, which is that one process can starve the rest of the system.
Only broken priority-based schedulers have that property. One of my incomplete fixes uses weights: Index: kern_synch.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_synch.c,v retrieving revision 1.167 diff -u -2 -r1.167 kern_synch.c --- kern_synch.c 18 Dec 2001 00:27:17 -0000 1.167 +++ kern_synch.c 19 Dec 2001 16:01:26 -0000 @@ -936,18 +1058,18 @@ struct thread *td; { - struct kse *ke = td->td_kse; - struct ksegrp *kg = td->td_ksegrp; + struct ksegrp *kg; - if (td) { - ke->ke_cpticks++; - kg->kg_estcpu = ESTCPULIM(kg->kg_estcpu + 1); - if ((kg->kg_estcpu % INVERSE_ESTCPU_WEIGHT) == 0) { - resetpriority(td->td_ksegrp); - if (kg->kg_pri.pri_level >= PUSER) - kg->kg_pri.pri_level = kg->kg_pri.pri_user; - } - } else { + if (td == NULL) panic("schedclock"); - } + td->td_kse->ke_cpticks++; + kg = td->td_ksegrp; +#ifdef NEW_SCHED + kg->kg_estcpu += niceweights[kg->kg_nice - PRIO_MIN]; +#else + kg->kg_estcpu++; +#endif + resetpriority(kg); + if (kg->kg_pri.pri_level >= PUSER) + kg->kg_pri.pri_level = kg->kg_pri.pri_user; } Most of the changes here are to fix style bugs. In the NEW_SCHED case, the relative weights for each priority are determined by the niceweights[] table. kg->kg_estcpu is limited only by INT_MAX and priorities are assigned according to relative values of kg->kg_estcpu (code for this is not shown). The NEW_SCHED case has not been tried since before SMPng broke scheduling some more by compressing the priority ranges. Bruce To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message