Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA18801; Mon, 5 Feb 96 20:46:29 EST
Received: from liquor.cabi.net by MIT.EDU with SMTP
	id AA29328; Mon, 5 Feb 96 20:46:18 EST
Received: by liquor.cabi.net (8.7.3/8.7.3) id SAA25658; Mon, 5 Feb 1996 18:33:17 -0500
Resent-Date: Mon, 5 Feb 1996 18:33:17 -0500
X-Sender: chapman@saul1.u.washington.edu
Date: Mon, 5 Feb 1996 15:29:54 -0800 (PST)
From: Randy Chapman <chapman@u.washington.edu>
To: Peter Busser <peter@vpro.nl>
Cc: java-linux@java.blackdown.org
Subject: Re: Does Linux Java block?
In-Reply-To: <m0tjMKR-000NbuC@2hoog.vpro.nl>
Message-Id: <Pine.OSF.3.91l.960205152534.22308M-100000@saul1.u.washington.edu>
Foo: foo-bar
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Resent-Message-Id: <"dMRXt1.0.hF6.CDf5n"@liquor>
Resent-From: java-linux@java.blackdown.org
X-Mailing-List: <java-linux@java.blackdown.org> archive/latest/1059
X-Loop: java-linux@java.blackdown.org
Precedence: list
Resent-Sender: java-linux-request@java.blackdown.org

On Mon, 5 Feb 1996, Peter Busser wrote:

> Howdy!
> 
> When I wrote a few small network servers in Java, I noticed that the Java
> runtime is always in a runnable state. On fast computers it is not so obvious,
> but on a 386DX40, with several sockets waiting for connection, it is. When I
> looked with strace it showed that the runtime polls the sockets continuously.
> This also happens when there is only one socket waiting.

It should only poll each socket once every 20ms.  Still rather lame.

> Is that because the Linux Java does not have kernel threads? Is there something
> to do about it (except implementing kernel threads)?

Well, thats the tricky part.  The Solaris version doesnt have this problem.
It uses SIGIO to notify the program when there is something.  Linux's
SIGIO isnt as good.  For starters, it only works on sockets, not on pipes
or tty's, so coding around that will be tricky (differing timeout-and-retry
times on different fd's).  Secondly, there is no way to get the Linux
to tell one which fd is now available... so I will have to either
a) wake up all threads waiting on IO or b) keep a global set of 
FDs to select() on to see.  I believe runtime support for the latter
is mostly in the SOlaris code, I'll see.

You are free to fix it yourself, or you'll need to wait for me to fix it.
(or someone else).  Its pretty high on my list of things to fix...

--randy

> 
> Groetjes,
> Peter Busser
> -- 
> UNIX sysadmin, database admin, TCP/IP netadmin, security specialist
> Tel.: +31-35-712709
> I'm the operator with my pocket calculator... (t/m 31 maart, daarna niet meer)
> 
> 

