Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 6181 invoked from network); 10 Nov 2006 09:12:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Nov 2006 09:12:32 -0000 Received: (qmail 34818 invoked by uid 500); 10 Nov 2006 09:12:41 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 34341 invoked by uid 500); 10 Nov 2006 09:12:39 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 34332 invoked by uid 99); 10 Nov 2006 09:12:39 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 01:12:39 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of a.y.chernyshev@gmail.com designates 64.233.182.185 as permitted sender) Received: from [64.233.182.185] (HELO nf-out-0910.google.com) (64.233.182.185) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Nov 2006 01:12:26 -0800 Received: by nf-out-0910.google.com with SMTP id p46so1132417nfa for ; Fri, 10 Nov 2006 01:12:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OHaYE3AfrKXPtb3RqRNxIpL8FhEdc2DWKzq+x/R0ruVECWBy9XiYJafSvmWRTy6664XXkDAfpFQPZyLzo3bdeWHV4ZV8d9j1e9GkEmIMJfCETQV/6AKMWbR0cX3HPI76NY6IrR8cayD17+HtJbmM4x8wiQ1op+ZLs9t40J9KEVY= Received: by 10.82.107.15 with SMTP id f15mr310178buc.1163149924810; Fri, 10 Nov 2006 01:12:04 -0800 (PST) Received: by 10.82.161.2 with HTTP; Fri, 10 Nov 2006 01:12:04 -0800 (PST) Message-ID: <6928c5160611100112n2960fd1bve243c1d4f2bc4adb@mail.gmail.com> Date: Fri, 10 Nov 2006 12:12:04 +0300 From: "Andrey Chernyshev" To: harmony-dev@incubator.apache.org Subject: Re: [drlvm][classlib] thread library - let there be one! In-Reply-To: <3ae04f990610260745u7ea18e27k35c5825c2c2fda1@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4533915B.8030201@pobox.com> <187bb05d0610160721j3ad43530l8a7a9857e9da5939@mail.gmail.com> <3ae04f990610171457x473b9613o3025847aed134710@mail.gmail.com> <187bb05d0610190804o611fdbd0u9d064e752545408@mail.gmail.com> <3ae04f990610231045s3aa4c0ddg2452d477879566e1@mail.gmail.com> <4dd1f3f00610240432v51f2d531obebdd5a9ef6f1789@mail.gmail.com> <3ae04f990610240934r4b2b6266o9f998455829e8550@mail.gmail.com> <4dd1f3f00610241447i3f0ce6d2h7d2ad75382be7334@mail.gmail.com> <3ae04f990610260745u7ea18e27k35c5825c2c2fda1@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org On 10/26/06, Angela Lin wrote: > On 10/24/06, Weldon Washburn wrote: > > > > If an arbitrary commercial JVM decided to use classlib, will it need to be > > modified to reflect the existing Harmony Classlib threading model? > > This is the case no matter how you split the thread library. Whatever > interface you specify for the classlib will need to be supported by > the VM. > > > Also, does this mean VM design is constrained by classlib design? And > > classlib design is constrained by J9 design? > > The classlib and the VM have certain dependencies on each other. This > is not a J9-specific issue. > > I would aim for a thread API that is generic enough to support > multiple implementations. I think it may be hard (if possible at all) to create high-level threading library which would make just every VM happy. For instance, DRLVM has a complex synchronization scheme with garbage collector which is built into the threading library (for example, each time thread goes into wait state, it must instruct the GC that the thread can be garbage collected). There also could be VM-specific optimizations for monitors which are tied to the object layout used in a particular VM. Finally, there might be pure-Java written VM's which may choose to implement threading library almost entirely in Java (may be on top of j.u.concurrent API ?), borrowing probably only park/unpark, atomic and may be sort of fork operations from the native code. How could we have a threading library which will work equally for all VM's? I agree that bypassing layer (2) by the classlib can be undesirable because of loosing track for thread/lock states. So it seems that: - both VM and classlib need to use single thread library, and at the same level (or, saying that differently, Java code and native code from classlib should use same threading lib); - threading lib is likely be VM-specific (consider DRLVM as an example) If we agree with the above, doesn't it just mean that the hythr must be declared as a part of VM? Classlib may probably continue to keep a "stub" library for the compilation purposes. But there must be the possibility for other VM's to easily replace it with it's own version. I guess we do something similar with the luni-kernel-stubs.jar. > > Mature VMs that switch to the Harmony classlib would probably > implement a portability layer between the existing VM's thread model > and the Harmony thread API. I guess mature VM's would likely to have their own very carefully written and optimized threading libraries, integrated with GC, JIT e.t.c. It will be easier for them to provide a suitable interface for classlib rather than rewrite VM on top of hythread, no matter how perfect is it. > > Has anyone considered how ThreadMXBean would be supported by the > proposed classlib thread API subset? May be ThreadMXBean is just a good candidate for the kernel class set? At least the spec says "interface for the thread system of the Java virtual machine". I guess other MXBeans are also interfaces to some of VM services. Thanks, Andrey. > > > On 10/24/06, Angela Lin wrote: > > > > > > Consider the group of monitor-related functionality: enter/exit, > > > wait/notify, and interrupt. The implementations of these functions are > > > closely related in the J9-derived hythread, particularly for 3-tier > > > locking. We need to coordinate when we lock the thread mutex, when we > > > lock the monitor mutex, how we use spinlocks, etc. It would be > > > unnatural to split out enter/exit from this group. > > > > > > > > > > On 10/24/06, Weldon Washburn wrote: > > > > On 10/23/06, Angela Lin wrote: > > > > > > > > > > What is the goal here? > > > > > > > > > > 1. If the goal is to create a single thread library that can be used > > > > > by multiple VM and classlib implementations, then the unified thread > > > > > lib should contain everything needed to support a VM implementation. > > > > > > > > > > 2. If the goal is to simply define the interface between the classlib > > > > > and the VM, then the 3rd option may be acceptable. This option seems > > > > > to imply splitting up functionality that requires deep knowledge of > > > > > the threading implementation, which I don't like. Each VM > > > > > implementation would need to implement both the VM and classlib sides > > > > > of the API. > > > > > > > > Is this really the situation? If Classlib only needs monenter/exit, TLS > > > and > > > > thread_create(), the "deep knowledge" required is probably only > > > > monitorenter/exit which seems like a managable situation. > > > > > > > > > > > > Regards, > > > > > Angela > > > > > > > > > > On 10/19/06, Artem Aliev wrote: > > > > > > Angela, all, > > > > > > > > > > > > I see you point and agree. > > > > > > But if we move hythread lib to the VM we will require all VMs fully > > > > > support it. > > > > > > Is it necessary dependency? > > > > > > > > > > > > So Here is the third way I see. > > > > > > Leave the minimum implementation of hythread in the classlib, with > > > the > > > > > > set of functions any VM should provide for classlib. > > > > > > This will simplifies adopting classlib to new VM and allows to > > > have > > > > > > solid threading model. > > > > > > So any VM could have its own super set of threading functions. > > > > > > > > > > > > Note: Classlib uses only monitor, TLS, and thread_create() from > > > > > hythread. > > > > > > > > > > > > Thanks > > > > > > Artem > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 10/18/06, Angela Lin wrote: > > > > > > > Artem et al, > > > > > > > > > > > > > > Sorry for jumping in late here. > > > > > > > > > > > > > > I maintain the J9VM thread lib. > > > > > > > > > > > > > > Option 1 worries me because it implies that the classlib could use > > > a > > > > > > > different threading model from the VM. This is bad because they > > > both > > > > > > > operate on the same threads. > > > > > > > > > > > > > > For example: Layer (2) of hythread might include internal thread > > > state > > > > > > > tracking, which is needed to support inspecting the thread state. > > > > > > > Using layer (1) directly would bypass the thread state tracking. > > > > > > > > > > > > > > Angela > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > Weldon Washburn > > Intel Middleware Products Division > > > > > -- Andrey Chernyshev Intel Enterprise Solutions Software Division