httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: Apache/pthread and locking problem
Date Thu, 12 Aug 1999 20:24:30 GMT
On Wed, 11 Aug 1999, Tony Finch wrote:

> Manoj Kasichainula <manojk@io.com> wrote:
> >
> >With the current socket APIs available, we need some way for the
> >processes to coordinate.
> 
> How about using a pipe for serialization? The threads inherit a
> socketpair from the parent process which has a byte written to it at
> startup. Before calling accept(), each thread does a blocking read
> from the pipe; when it gets a byte it drops through accept() then
> writes the byte back onto the pipe for another thread to read.

at some point it's probably easier to accept() in the parent and pass fds
to the children...  i worry about the pipe thing and context switches --
some kernels may prefer to context switch on the write(). 


btw, the userland thread library is going to have a central poll/select
call... and if multiple threads go through accept(3), they'll all be
aggregated into the one poll/select.  with a little tweaking, you can
easily ensure that when accept(2) finally returns EAGAIN, it won't be
called again until the poll/select indicates it's ready -- you can just
leave a bunch of the userland threads stuck blocked on accept(3). 

then you don't really need to synchronize between multiple processes,
because you've reduced your thundering herd, from, say 256, down to, say
8. 

Dean


Mime
View raw message