| plan 9 kernel history: overview | file list | diff list |
2003/0228/port/proc.c (diff list | history)
| 2003/0228/sys/src/9/port/proc.c:192,197 – 2003/0301/sys/src/9/port/proc.c:192,211 (short | long | prev | next) | ||
|
Scheduling tweak: even prioritized processes get penalized for running too long.
Bug fix: need to scan run queues twice, once again after lock acquired.
rsc Mon Mar 20 20:49:42 2006 | ||
| 2003/0228 | return 0; } | |
| 1995/0110 | ||
| 2003/0301 | /* * ready(p) picks a new priority for a process and sticks it in the * runq for that priority. * * - fixed priority processes never move * - a process that uses all its quanta before blocking goes down a * priority level * - a process that uses less than half its quanta before blocking * goes up a priority level * - a process that blocks after using up half or more of it's quanta * stays at the same level * * new quanta are assigned each time a process blocks or changes level */ | |
| 1990/0227 | void ready(Proc *p) { | |
| 2003/0228/sys/src/9/port/proc.c:214,228 – 2003/0301/sys/src/9/port/proc.c:228,235 | ||
| 2003/0228 | } else if(p->state == Running){ if(p->quanta <= 0){ /* degrade priority of anyone that used their whole quanta */ | |
| 2003/0301 | if(pri > 0) pri--; | |
| 2003/0228 | p->quanta = quanta[pri]; } | |
| 1995/0110 | } else { | |
| 2003/0228/sys/src/9/port/proc.c:256,262 – 2003/0301/sys/src/9/port/proc.c:263,269 | ||
| 1990/0227 | runproc(void) { | |
| 2003/0228 | Schedq *rq; | |
| 1995/0110 |
| |
| 2003/0301 | Proc *p, *l, *tp; | |
| 2002/0822 | ulong start, now; | |
| 2003/0228 | int i; | |
| 1990/0227 | ||
| 2003/0228/sys/src/9/port/proc.c:274,292 – 2003/0301/sys/src/9/port/proc.c:281,301 | ||
| 1992/0603 | spllo(); | |
| 2003/0228 | for(i = 0;; i++){ /* | |
| 2003/0301 | * find the highest priority target process that this | |
| 2003/0228 | * processor can run given affinity constraints */ for(rq = &runq[Nrq-1]; rq >= runq; rq--){ | |
| 2003/0301 | tp = rq->head; if(tp == 0) | |
| 2003/0228 | continue; | |
| 2003/0301 | for(; tp; tp = tp->rnext){ if(tp->mp == nil || tp->mp == MACHP(m->machno) || (!tp->wired && i > 0)) | |
| 2003/0228 | goto found; | |
| 1998/0901 | } | |
| 1995/0110 | } | |
| 2002/0822 | ||
| 2003/0301 | /* waste time or halt the CPU */ | |
| 2000/1130 | idlehands(); | |
| 2003/0228 | /* remember how much time we're here */ | |
| 2003/0228/sys/src/9/port/proc.c:300,308 – 2003/0301/sys/src/9/port/proc.c:309,321 | ||
| 1997/0821 | if(!canlock(runq)) goto loop; | |
| 1991/0420 | ||
| 2003/0301 | /* * the queue may have changed before we locked runq, * refind the target process. */ | |
| 1995/0110 | l = 0; for(p = rq->head; p; p = p->rnext){ | |
| 2003/0228 |
| |
| 2003/0301 | if(p == tp) | |
| 1995/0110 | break; l = p; | |
| 1994/0728 | } | |