On Sun, 23 Jan 2000, Warner Losh wrote:
> : This is what I asked for, when I asked for "other specification". Could
> : you provide the chapter/verse number of where POSIX spec contradicts the
> : man pages? It will help me make my case on the TCL forum, since the TCL
> : developers remain under the mistaken assumption, that select() may
> : return earlier, but never later than specified.
>
> That's trivially easy to show.
In theory, but not in practice :-).
> Given process X with a priority N + 1 that is doing
N - 1 (higher priority is actually "lower")
> while (1) ;
> while process Y with a priority of N is doing the select. The kernel
> won't prempt X until the time slice is done, which can be a long
> time. If the select'd process is swapped out, then it could take a
> very very long time to swap back in.
Um, if the priorities are actually N vs. N - 1, then the process with
priority N won't run at the end of the timeslice. It will only run
when its priority becomes "lower", possibly several timeslices later.
In practice, the priorities will never be N vs. N - 1. The process
doing the select() sleeps at priority PSOCK = 24. The process doing
the while loop should always have priority >= PUSER = 50, but due to
a bug (?) in nice(2), the priority of a nice --20 process can be as
low as PUSER - 20 = 30. Anyway, that is > PSOCK, so the process doing
the select() will preempt the user process and wake up as soon as it
times out. Then, due to a longstanding scheduling bug (?), the process
doing the select() will return to userland without being rescheduled,
although its user priority may be much "higher" than that of any other
runnable process. Processes that do i/o are thus preferred to cpu
hogs much more strongly than their priorities indicate. This bug is
a feature in most cases. It reduces context switches. Interactive
process may get more benefit from it than from the classical scheduling
preference for interactive processes.
Bruce
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message