Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!vsi1!zorch!xanthian From: xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) Newsgroups: comp.sys.amiga.programmer Subject: Re: How do we change the scheduler? (Was Re: Multitasking at home...) Message-ID: <1991Jan15.224047.6986@zorch.SF-Bay.ORG> Date: 15 Jan 91 22:40:47 GMT References: <1991Jan10.130741.11570@ux1.cso.uiuc.edu> Organization: SF-Bay Public-Access Unix Lines: 38 Aging isn't that terribly tricky; you want to bump a little the process' chance to have its priority raised, every time it surrenders control with a "wait", and bump a little the process' chance to have its priority lowered, every time it is still executing at the end of its time slice, and surrenders control to the timer interrupt instead. You bump a little the chance of processes in the ready queue but not at the highest priority in that queue having their priority raised once in a while. The former processes are intuitively "i/o hungry" and should get better cpu service, the middle processes are intuitively "cpu hungry" and so should be restrained to allow others a better chance at the cpu when they need it, the latter processes are intuitively cpu starved and need their odds of getting a slice improved. The details have flown, but a combination of adding/subtracting amounts that depend on the process' existing priority to a single counter for each process, and occasionally shifting all the counters right to prevent overflow and suppress/age older information, and then once a tenth-second or so revising all the process priorities if their associated counters have reached a trip value plus or minus, is all that is required to accomplish aging of priorities. (The paradigm described is called "exponential aging", if I remember aright.) If the amounts added for cpu starved processes are more than enough to compensate for the bit shifting over time, those processes will age into higher priorities. If processes surrender control with a wait much more often than to the timer, their priorities will rise, if they surrender control much more often to the timer than to i/o waits, their priorities will fall (as is appropriate; processes that are not doing i/o are not real time processes, and so can afford to wait for those that are); if they do a mix of timer and wait surrenders, then with correctly balanced increment quantities, the priority will be stable. Kent, the man from xanth.