chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] How to avoid busy waiting when using tcp-accept and thre


From: Sven Hartrumpf
Subject: [Chicken-users] How to avoid busy waiting when using tcp-accept and threads?
Date: Tue, 25 Feb 2003 10:01:23 +0100 (CET)

On 24 Feb 2003, felix <address@hidden> wrote: 
> Sven Hartrumpf wrote:
> > I have a server program that serves client requests in parallel using
> > chicken threads. The main structure of the server is given below.
> > Currently, even before the first request comes in, the server needs 100%
> > cpu time. The server is the only thread at that time and stays in the
> > first part of the loop because tcp-accept-ready? returns #f. This is
> > as intended, but how can I avoid this busy waiting?
> > 
> 
> Currently not. tcp-accept is non-blocking exactly because we want
> other threads to run.

But if there are no other runnable threads, we currently "block" (= consume)
the whole CPU power :-)

> But perhaps we can add a little hack: if no other threads are running
> *or* blocked for timeout/input, we can do a blocking accept().
> 
> Would this work?

Yes, I think this would work in situations like the one I reported above.

Ciao
Sven




reply via email to

[Prev in Thread] Current Thread [Next in Thread]