You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Weldon Washburn <we...@gmail.com> on 2007/03/06 01:55:17 UTC

[drlvm][threading] a question about JIRA H3253

Peter,
I modified your patch to put the variables inside the critical section.  Let
me know if the following is not OK


public Thread.State getState() {

boolean dead = false;

synchronized(lock) {

if(started && !isAlive() ) dead = true;

}

if (dead) return State.TERMINATED;

int state = (VMThreadManager.getState(this));


-- 
Weldon Washburn
Intel Enterprise Solutions Software Division

Re: [drlvm][threading] a question about JIRA H3253

Posted by Salikh Zakirov <Sa...@Intel.com>.
Weldon Washburn wrote:
> Peter,
> I modified your patch to put the variables inside the critical section. 
 >
> public Thread.State getState() {
>     boolean dead = false;
>     synchronized(lock) {
>         if(started && !isAlive()) 
>             dead = true;
>     }
> 
> if (dead) return State.TERMINATED;
> 
> int state = (VMThreadManager.getState(this));

Weldon,

I think the more correct way would be to make sure that the
VMThreadManager.getState() is called while holding the thread lock, like this way

public Thread.State getState() {
    synchronized (lock) {
        if  (!alive)
            return started ? State.TERMINATED : State.NEW;
        int state = VMThreadManager.getState(this);
    }
    ...

This way, we have two benefits:

1) the code is easier to judge about, because holding thread lock guarantees
that thread is not changing its alive status while we are calling into
VMThreadManager

2) in this way it is compatible with the explicit thread block lifecycle
(HARMONY-3289)

BTW, the State.NEW also deserves special treatment, as it is not necessary
to call into native code to detect that. While it would not be incorrect,
because native structure is allocated at the same time as java.lang.Thread
object, I think decreasing coupling of java code with native is good where
possible.

-- 
Salikh Zakirov


Re: [drlvm][threading] a question about JIRA H3253

Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
I don't agree - I think that was a perfectly good question for the  
dev list.

geir

On Mar 5, 2007, at 10:43 PM, Rana Dasgupta wrote:

> IMHO we may be better off if we post brief discussions on commits/ 
> reviews on
> the JIRA, rather than on the list, unless it is an architectural  
> issue or
> one where several opinions could add value. There seem to be  
> several threads
> where the entire thread consists of a single post and a response :-)
>
> On 3/5/07, Weldon Washburn <we...@gmail.com> wrote:
>>
>> Peter,
>> I modified your patch to put the variables inside the critical
>> section.  Let
>> me know if the following is not OK
>>
>>
>> public Thread.State getState() {
>>
>> boolean dead = false;
>>
>> synchronized(lock) {
>>
>> if(started && !isAlive() ) dead = true;
>>
>> }
>>
>> if (dead) return State.TERMINATED;
>>
>> int state = (VMThreadManager.getState(this));
>>
>>
>> --
>> Weldon Washburn
>> Intel Enterprise Solutions Software Division
>>


Re: [drlvm][threading] a question about JIRA H3253

Posted by Rana Dasgupta <rd...@gmail.com>.
OK, it's just a thought.
Some of the JIRA comments are excellent and focussed actually. Somehow most
concerned parties seem to find their way there :-)


On 3/7/07, Geir Magnusson Jr. <ge...@pobox.com> wrote:
>
>
> On Mar 6, 2007, at 10:52 AM, Rana Dasgupta wrote:
>
> > My thought was that if we have a JIRA related "discussion" on the
> > list, the
> > intent is possibly to invite more comments, not just from the
> > submitter and
> > reviewer. If one feels that this broader participation or interest is
> > necessary, it may be a good idea for whoever posts it on the list
> > to add a
> > few words to provide some context and background on the problem, which
> > should not be hard to do. Otherwise, the discussion stays closed.
>
> But I think that we always want to invite broader participation and
> interest.  if people bite, great.  If they don't, no harm done.
>
> I actually engaged on weldons question, looking at what he was
> talking about.  I hate reading through JIRa comments :)
>
> geir
>
> >
> >
> >
> > On 3/6/07, Salikh Zakirov <Sa...@intel.com> wrote:
> >>
> >> Rana Dasgupta wrote:
> >> > IMHO we may be better off if we post brief discussions on
> >> > commits/reviews on
> >> > the JIRA, rather than on the list, unless it is an architectural
> >> issue
> >> or
> >> > one where several opinions could add value. There seem to be
> >> several
> >> > threads
> >> > where the entire thread consists of a single post and a
> >> response :-)
> >>
> >> Rana,
> >>
> >> there is nothing wrong in a single post and a response, because the
> >> purpose of
> >> harmony-dev posting is to discuss things *in public*, rather than
> >> having
> >> hot
> >> discussions all the time.
> >>
> >> Should Weldon posted his comment in JIRA, I would probably miss it.
> >>
> >> And, by the way, using locks *is* an architectural issue.
> >>
> >>
>
>

Re: [drlvm][threading] a question about JIRA H3253

Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Mar 6, 2007, at 10:52 AM, Rana Dasgupta wrote:

> My thought was that if we have a JIRA related "discussion" on the  
> list, the
> intent is possibly to invite more comments, not just from the  
> submitter and
> reviewer. If one feels that this broader participation or interest is
> necessary, it may be a good idea for whoever posts it on the list  
> to add a
> few words to provide some context and background on the problem, which
> should not be hard to do. Otherwise, the discussion stays closed.

But I think that we always want to invite broader participation and  
interest.  if people bite, great.  If they don't, no harm done.

I actually engaged on weldons question, looking at what he was  
talking about.  I hate reading through JIRa comments :)

geir

>
>
>
> On 3/6/07, Salikh Zakirov <Sa...@intel.com> wrote:
>>
>> Rana Dasgupta wrote:
>> > IMHO we may be better off if we post brief discussions on
>> > commits/reviews on
>> > the JIRA, rather than on the list, unless it is an architectural  
>> issue
>> or
>> > one where several opinions could add value. There seem to be  
>> several
>> > threads
>> > where the entire thread consists of a single post and a  
>> response :-)
>>
>> Rana,
>>
>> there is nothing wrong in a single post and a response, because the
>> purpose of
>> harmony-dev posting is to discuss things *in public*, rather than  
>> having
>> hot
>> discussions all the time.
>>
>> Should Weldon posted his comment in JIRA, I would probably miss it.
>>
>> And, by the way, using locks *is* an architectural issue.
>>
>>


Re: [drlvm][threading] a question about JIRA H3253

Posted by Rana Dasgupta <rd...@gmail.com>.
My thought was that if we have a JIRA related "discussion" on the list, the
intent is possibly to invite more comments, not just from the submitter and
reviewer. If one feels that this broader participation or interest is
necessary, it may be a good idea for whoever posts it on the list to add a
few words to provide some context and background on the problem, which
should not be hard to do. Otherwise, the discussion stays closed.



On 3/6/07, Salikh Zakirov <Sa...@intel.com> wrote:
>
> Rana Dasgupta wrote:
> > IMHO we may be better off if we post brief discussions on
> > commits/reviews on
> > the JIRA, rather than on the list, unless it is an architectural issue
> or
> > one where several opinions could add value. There seem to be several
> > threads
> > where the entire thread consists of a single post and a response :-)
>
> Rana,
>
> there is nothing wrong in a single post and a response, because the
> purpose of
> harmony-dev posting is to discuss things *in public*, rather than having
> hot
> discussions all the time.
>
> Should Weldon posted his comment in JIRA, I would probably miss it.
>
> And, by the way, using locks *is* an architectural issue.
>
>

Re: [drlvm][threading] a question about JIRA H3253

Posted by Salikh Zakirov <Sa...@Intel.com>.
Rana Dasgupta wrote:
> IMHO we may be better off if we post brief discussions on
> commits/reviews on
> the JIRA, rather than on the list, unless it is an architectural issue or
> one where several opinions could add value. There seem to be several
> threads
> where the entire thread consists of a single post and a response :-)

Rana,

there is nothing wrong in a single post and a response, because the purpose of
harmony-dev posting is to discuss things *in public*, rather than having hot
discussions all the time.

Should Weldon posted his comment in JIRA, I would probably miss it.

And, by the way, using locks *is* an architectural issue.


Re: [drlvm][threading] a question about JIRA H3253

Posted by Rana Dasgupta <rd...@gmail.com>.
IMHO we may be better off if we post brief discussions on commits/reviews on
the JIRA, rather than on the list, unless it is an architectural issue or
one where several opinions could add value. There seem to be several threads
where the entire thread consists of a single post and a response :-)

On 3/5/07, Weldon Washburn <we...@gmail.com> wrote:
>
> Peter,
> I modified your patch to put the variables inside the critical
> section.  Let
> me know if the following is not OK
>
>
> public Thread.State getState() {
>
> boolean dead = false;
>
> synchronized(lock) {
>
> if(started && !isAlive() ) dead = true;
>
> }
>
> if (dead) return State.TERMINATED;
>
> int state = (VMThreadManager.getState(this));
>
>
> --
> Weldon Washburn
> Intel Enterprise Solutions Software Division
>