[Techtalk] Kernel Stuff (was Re: Theory vs. practice)
val at nmt.edu
Tue Jan 15 19:31:19 EST 2002
On Tue, Jan 15, 2002 at 03:19:11PM -0800, Kai MacTane wrote:
> At 1/15/02 02:29 PM , Val Henson wrote:
> >Linux gets around this by introducing the concept of "fairness" (I'm
> >ignoring the "realtime" priorities). Each process does eventually get
> >to run for a while, even if a higher priority process still wants the
> >CPU. It's very egalitarian. :)
> So, essentially, let me see if I've got this straight: the teller starts
> counting the old lady's pennies, then after a few minutes goes, "Hmmm, I'd
> better see what those other people want." Jots down how many pennies have
> already been counted, asks the old lady to hold on for a minute, briefly
> steps over to another window (so as not to mess up all those pennies), and
> says, "Excuse me? Next in line? Can I help you with something?"
> Silver account dude deposits his $100 and leaves, then the teller sees that
> the Platinum account can now be serviced. So sie calls out to the Platinum
> lady, "I can finish your transaction at this window," does it, then gets
> back to the drudgery of the old lady with the pennies.
> Is this about right?
Yes. You've just come up with the idea of a "timeslice." Each person
gets the teller for say, 10 minutes, and then a timer goes off and the
teller stops helping that person and looks around to see if anyone
else needs help. Being a fair and nice teller, she also takes into
account how long the person has been waiting when she's deciding who
to help next. You're right, she needs to either switch windows (a
SPARC strategy called "register windows"), or she needs to save all of
the old lady's information (and pennies) somewhere else (the stack,
which the x86 and most others use).
Timeslices get interesting. What happens if the kernel gets an disk
interrupt during a process's timeslice? In our analogy, this would be
the bank manager asking the teller a question that takes 30 seconds to
answer. The teller could try to keep track of how much time she spent
answering the question and then reset her 10 minute timer to go off 30
seconds later, but that would probably take longer than the 30 second
question itself, so she doesn't bother. This isn't fair, but it's
> I'd love to hear about it, once I'm sure I've got a firm
> understanding of the current situation. And I love the idea someone
> had of letting people guess.
You understand it just fine. :)
More information about the Techtalk