Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 90144 invoked from network); 8 Oct 2007 13:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Oct 2007 13:27:15 -0000 Received: (qmail 36069 invoked by uid 500); 8 Oct 2007 13:27:02 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 36050 invoked by uid 500); 8 Oct 2007 13:27:01 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 36041 invoked by uid 99); 8 Oct 2007 13:27:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 06:27:01 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of alexander.n.alexeev@gmail.com designates 64.233.162.229 as permitted sender) Received: from [64.233.162.229] (HELO nz-out-0506.google.com) (64.233.162.229) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 13:27:04 +0000 Received: by nz-out-0506.google.com with SMTP id o37so673672nzf for ; Mon, 08 Oct 2007 06:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=tPZB9rUgWClTMhfKvi4EAqMSH5QHMZagSJ/Y4VL4rX0=; b=mfoY7le1ftoA5nyS5cwmXxKnAnc0f2Qo4DJmeGqgBS7Gt81ac9tZ7s1SL2KiWvHQe3AHB5NSiAPg6aWTh2pyIiDn99fcpIPYgHVms5vqiHNKfUqz26ig9IL6W5AK02kWsy42Q3+f2IEsSEaZ9JvucnDUm3vFJuCYxbBmAcU3XrQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PQ156lftdXeROCBigW5xv6FXChczDzDmngi29QSNnPbsbHfuvtHL0tq4AUWyg2D+Qm6vuumfReahZ+SgwYiUH4MHlI6CtXGCtqLS4S8zPJTMLF4yoe0WXNkk/BnToZAh7QZ3JE/KNrIev+0zg8Kcpzh6Cebs42aG/T9J6NSlzEY= Received: by 10.65.244.15 with SMTP id w15mr25185124qbr.1191850003484; Mon, 08 Oct 2007 06:26:43 -0700 (PDT) Received: by 10.65.241.1 with HTTP; Mon, 8 Oct 2007 06:26:43 -0700 (PDT) Message-ID: <9edfd6e10710080626x6a4f32fcqf653be29ccd88391@mail.gmail.com> Date: Mon, 8 Oct 2007 17:26:43 +0400 From: "Alexander Alexeev" To: dev@harmony.apache.org Subject: Re: [drlvm][jvmti] Thread's state after Join invocation is debatable In-Reply-To: <4dd1f3f00710060834g6da02ab2j32888dd47a80962e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9edfd6e10710050555l3cd92949x3fc01b9578cf1ae5@mail.gmail.com> <9edfd6e10710050844i1512f4c3ycac0443973318e2d@mail.gmail.com> <4dd1f3f00710060834g6da02ab2j32888dd47a80962e@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi. I've created HARMONY-4905. Test case attached. Alex. On 10/6/07, Weldon Washburn wrote: > Alexander, > > Would it be possible for you to write a simple test that demonstrates > the inconsistent behavior? > > On 10/5/07, Alexander Alexeev wrote: > > Pavel, looking on the code I can't understand why different events are > > sent just before wait thread is blocked inside lock.wait(). In both > > cases JVMTI_EVENT_MONITOR_WAIT should be sent, there is no contention > > for monitors on enter to lock.wait(). > > > > Is wait thread blocked inside lock.wait() before waited thread terminated? > > > > Maybe you misunderstand me. > > Lets define two threads :) > > T1 - long running job > > T2 - is waiting for T1 termination > > > > I am interested in event which is rose just after T2 calls join method > > for T1, and T1 still continue execution and T2 become blocked and > > wait. > > > > > > > 2. Should it be? What is proper thread's state depiction? > > I think it should. Proper state is "wait" because it corresponds with > > expectation about what is happening with thread, it is waiting another > > termination but isn't competing for monitor. > > Also it corresponds with other VMs behavior. > > > > Thanks. > > Alex. > > > > On 10/5/07, Pavel Rebriy wrote: > > > Hello Alexander > > > > > > Here is an instance of Thread.join() implementation: > > > > > > public final void join() throws InterruptedException { > > > synchronized (lock) { > > > while (isAlive()) { > > > lock.wait(); > > > } > > > } > > > } > > > > > > If joined thread is dead we don't go to wait and the last event is > > > JVMTI_EVENT_MONITOR_CONTENDED_ENTER. In case of the following code: > > > > > > public final void join() throws InterruptedException { > > > synchronized (lock) { > > > do { > > > lock.wait(); > > > } while (isAlive()); > > > } > > > } > > > > > > the last event will be JVMTI_EVENT_MONITOR_WAIT. So the answers are: > > > > > > 1. No, such kind of behavior is not defined in spec. > > > 2. Should it be? What is proper thread's state depiction? > > > > > > > > > On 05/10/2007, Alexander Alexeev wrote: > > > > > > > > Hi, All. > > > > > > > > I've faced the following difference in Harmony JVM TI behavior in > > > > comparison with other JVMs. > > > > > > > > When one thread spawns another and joins it, waiting for its > > > > termination, it becomes blocked on monitor (from last handled event > > > > JVMTI_EVENT_MONITOR_CONTENDED_ENTER for that thread before 'sleep") , > > > > while in other VMs (Sun's, IBM's and BEA's) thread which calls "Join" > > > > starts waiting (last event is JVMTI_EVENT_MONITOR_WAIT before > > > > 'sleep"). Probably set of events depends on VM internals, but in > > > > common sense "waited" state is more suitable for thread which waits > > > > for other thread termination. > > > > > > > > 1. Can such kind of behavior be defined in any specs? > > > > 2. Could it be fixed, i.e. from blocked to waited state during join? > > > > This is required for proper thread's state depiction in tools. > > > > > > > > Alex. > > > > > > > > > > > > > > > > -- > > > Best regards, > > > Pavel Rebriy > > > > > > > > -- > Weldon Washburn >