Received: from SOUTH-STATION-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA25297; Fri, 12 Jan 96 01:09:18 EST
Received: from liquor.cabi.net by MIT.EDU with SMTP
	id AA16738; Fri, 12 Jan 96 01:09:20 EST
Received: (from listadm@localhost) by liquor.cabi.net (8.6.12/8.6.12) id BAA14881; Fri, 12 Jan 1996 01:12:36 -0500
Resent-Date: Fri, 12 Jan 1996 01:12:36 -0500
X-Sender: chapman@saul6.u.washington.edu
Date: Thu, 11 Jan 1996 22:06:45 -0800 (PST)
From: Randy Chapman <chapman@u.washington.edu>
To: Davide Rossi <rossi@cs.unibo.it>
Cc: java-linux@java.blackdown.org
Subject: Re: Threads and time quantum
In-Reply-To: <Pine.SUN.3.91.960111233809.948D-100000@despina>
Message-Id: <Pine.OSF.3.91l.960111215904.25005P-100000@saul6.u.washington.edu>
Foo: foo-bar
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Resent-Message-Id: <"88vj12.0.od3.UkVzm"@liquor>
Resent-From: java-linux@java.blackdown.org
X-Mailing-List: <java-linux@java.blackdown.org> archive/latest/930
X-Loop: java-linux@java.blackdown.org
Precedence: list
Resent-Sender: java-linux-request@java.blackdown.org


(does this really belong on java-linux-dev or here?)

On Thu, 11 Jan 1996, Davide Rossi wrote:
> Hello,
> meybe someone who knows more that I do about the thread library used to port
> java (Randy ?) could reply this question:
> if I have, say, 3 processes on my host that share fairly the cpu time.
> If a process runs 3 thread, each process/thread has the same time quantum 
> or threads get 1/3 respect other processes? 
> And what about other operating systems (win95, solaris, ...)?
> Just curious.

Ahh yes... very good question, actually =)

On Linux, as on Solaris (and on the Mac), Java is strictly one process 
using a completely user level threading implementation.  This means,
then, that if there are three threads in one process, and one each
in two others, each *process* as a *whole* gets the same amount of
processer time.  Thusly, the individual threads in one get 1/3 the
time as the one thread in the other process.

If the code were to use solaris threads, the many java threads of one
process would be split across a couple processes and (I assume),
thusly bringing the priorities of the threads of that process relative to
another process back up.

A simplistic linux kernel-based threads approach, otoh, would have each
thread in what, as far as the time-slicer is concerned, is a separate
task, thus each thread of the 3threaded app having the same priority
as a full single-threaded app.  Needless to say, this would allow some
nasty clone/thread bombs in java, hence why I dont like this idea =(

On MS-Windows, the java system uses kernel-based threads (which entain
just the one task switcher at the krnel level instead of the two).
I suspect, however, that the task as a whole has no more priority 
than any other task, so each thread is lower than those from single-threaded
applications.

On the relevance to programming in java side of the matter....
Windows threads are preemptive within the same priority level.
Solaris/Linux threads are not.  Beware.

--randy


> 
> Ciao,
> 	Davide.
> 
> 

