Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 1999 20:17:59 -0700
From:      "David Schwartz" <davids@webmaster.com>
To:        "Tani Hosokawa" <unknown@riverstyx.net>
Cc:        <chat@FreeBSD.ORG>
Subject:   RE: Known MMAP() race conditions ... ?
Message-ID:  <000301bece70$a40b5e20$021d85d1@youwant.to>
In-Reply-To: <Pine.LNX.4.10.9907142007120.2799-100000@avarice.riverstyx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Wed, 14 Jul 1999, David Schwartz wrote:
>
> >
> > > The current model is a hybrid thread/process model, with a number of
> > > processes each with a large number of threads in each, each thread
> > > processing one request. From what I've seen, 64
> threads/process is about
> > > right.  So, in one Apache daemon, you can expect to see >1000 threads,
> > > running inside 10-20 processes.  Does that count as a large number?
> > 	Yes. And it's bad design.
>
> I'm curious.  How would you do it?

	I would have a pool of threads and a job queue. Anything that can be done
without blocking would be considered a job. When the server had jobs to do,
it would queue them. The first 'free' thread would pull a job of the queue.
If while processing a job I needed to block for any reason, I'd instead
create a new job and set up to queue it when a particular network event
occured.

	At least one special thread would call 'poll' for the set of jobs waiting
for network I/O. When the network I/O could be completed without blocking,
the special thread would move the job from the network queue to the active
queue.

	When a thread became free, it would pull the head job off the active queue.
If the active queue were empty, it would sleep waiting for a new job.

	The basic idea is that any time where you presently block on network I/O,
you instead save your state and set it up so that when a 'poll' or 'select'
that tells you that the network I/O can be completed without blocking, you
pick up where you left off.

	DS



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000301bece70$a40b5e20$021d85d1>