httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Robert S. Thau)
Subject Re: project plan
Date Tue, 16 Jul 1996 01:00:11 GMT
  I've not looked at rst's thread
  implementation yet but there may be no context switch at all for an
  user space based implementation.

There's no switch of processor state, if that's what you mean (there
is a switch between stacks, of course, but that happens entirely
within user space and the kernel is not involved).  NB that it is
common even on systems that support kernel threads to map multiple
user-mode threads onto each kernel thread, precisely because the
overhead of context-switches among user-mode threads is lower.  (A
well-tuned pthreads implementation will do this sort of thing behind
the user's back, of course.  The recent Software: Practice &
Experience article on the Ariadne threads package has a fairly good
overview of the issues, among other good stuff).

However, returning to my package, there is still *currently* kernel
overhead at each context switch, in the form of a select() to
determine if any threads blocked on threaded I/O should now be marked
runnable.  These select()s are the prime suspect as to why
context-switch overhead exceeds what I'd like on profiles, and when
(if!) I finally get around to performance tuning, I'll be looking into
doing them less often.

(The bugaboo is that you don't want "while (1) rst_yield()" to lock
out threads which are blocked on I/O, so you do have to do an I/O poll
every so often even if there are other runnable threads lying around).


View raw message