A G F Keahan wrote:
> 
> > On Sun, Apr 23, 2000 at 09:21:15PM -0700, Jason Evans wrote:
> > >
> > > This design isn't ideal on any OS, but the fact that you do significant
> > > processing every time a request arrives on a socket probably hides most of
> > > the inefficiency due to thread switching and lack of cache locality due to
> > > many thread stacks.
> 
> Can you suggest a better design for this type of server application
> under FreeBSD?    Perhaps a combination of forking (or pre-forking) and
> threads?

Preallocate a number of threads that yeilds adequate peformance and feed
work to the threads via IPC mechanisms.  When the thread finishes its
work, rather than exiting, it just waits for another work unit.  A simple
way to do this is via a queue, or via a shared memory pool for each
thread and a "go" semaphore.

This avoids the overhead of thread startup and shutdown for every client
connection.

-- 
            "Where am I, and what am I doing in this handbasket?"

Wes Peters                                                         Softweyr LLC
[EMAIL PROTECTED]                                           http://softweyr.com/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to