Why "lock" functionality is introduced for all the objects?

S

Steve Erwin

I set it up that way initially because the news server
I use required a valid address.
.... many factors feed into which server to use where.
Seems you came, sat, and are happy, right?
xxxxxxxxxxxxxxxxxxxxxxxxxxxx I think they've changed
their policy, but since the e-mail address I use here is
basically a spamcatcher, I'm not strongly motivated to
try to disguise it.
mmm.. as a programmer have you ever studied any network
influences resulting from, let's say, 'poor' practices
of software, any software, like? I see any influence
over html as "software".
Just so as you might see my thrust :)
Eh, that's a good point. Hm. On the minus side, it does
somewhat inconvenience anyone who wants to reply by mail.
Then again, so few people have done so over the years (at
least, as far as I know) ....
Maybe your posts only attract the blind?
/grin

I do not do brail yet I could get mail to you in a
flash were your "From" to read;

"Massingill" <[email protected]>

... not that I would mail a gMail address.. jes sayin'
like, I could :)

Yes, quite. And that's okay with me -- since as best
I can tell your suggestion would result in just the
"(e-mail address removed)" displaying, which I don't want.
Interesting.
Cos it i s now... look at the scr.sht.
What is the difference?

errr.
[thinking]
... the double quotes do not "list"
only the text. I think you guys call quotes "switches".
To me they are "wrapping tags".. but we live in
different worlds,, I think.. mheh heh
Maybe so. But in the case of my rather peculiar "name"
I think it would result in something that might mislead
people.
crikey.. heh.. you got problems, lady! 8->

They call me "latzferfukendinner"... or "Hey You"
and I don't see that harming none!
Mum knows when I am hungry, no misleading
there :->
Of course I could pick a "name" that wasn't a now-obsolete
e-mail address, but I started out using the address
because I couldn't come up with a name I liked, and all
these years later I still can't -- not to mention that
there's the continuity issue.
oH there is that!!
It is sssooo important folks knows who we is on the
InnteeeNetz,, eh, muriel?
Eh. I think I'll leave it alone for now. I suppose if
there was a rash of posts agreeing with you I might change
my mind. XXXXXXXXXXXXXXXXXXXXXXX
You think anyone around here knows this stuff?
Really!?
Tell you what.. i f they did, not only would your name
have been changed/corrected waaaay back, but "we"Joe
Public types would have integrated seamless surfing of
pages like RS.com without having to jump through a
dozen friken hoops to get stuff working.
Take THAT to the bank! :-D
Thanks for the info anyway -- it *is* interesting
... no worries.

btw...
You know how I got onto Seamus's tail?
The guy could not find a +h sys file on his computer.
I can still hear him wailing to this day.
"I am telling you there is no such fucking file on my
computer. It may well be on your fucking computer but
it isn't on my fucking computer and my fucking computer
works, thank you so very fucking much for your fucking
no-help!"
Yeh, true!
This from a guy with a BSc in computer science, so he
says, and a whole list of languages under his belt.
Didn't even have a CLUE about +rash

nup.. sorry, got no time for the education of those who
believe a whole bunch of leaping flashing icons is
great for the networks.

BuuuT I guess someone has to keep the unemployable
employed.. might as well be the likes of
Gates/Turner etal :-D

The fact you are bothered to break thread, creating
a new topic, yet fixing your nym display isn't a big
deal to you... is very interesting. But I aint got the
time ..


cya 'roun

/0ff
 
B

blmblm

... many factors feed into which server to use where.
Seems you came, sat, and are happy, right?

Quite.

[ snip ]
Interesting.
Cos it i s now... look at the scr.sht.
What is the difference?

None. Why would there be a difference? I have not made
a change.
errr.
[thinking]
.. the double quotes do not "list"
only the text. I think you guys call quotes "switches".
To me they are "wrapping tags".. but we live in
different worlds,, I think.. mheh heh

Very possible (about different worlds), but if I had
to choose between those alternatives, "wrapping tags"
seems like a better fit than "switches" for text enclosed
in double quotes. I don't recognize the latter usage.
<shrug>

[ snip ]
The fact you are bothered to break thread, creating
a new topic, yet fixing your nym display isn't a big
deal to you... is very interesting. But I aint got the
time ..

"Break thread"? I'm following what I understood to be the
convention for signaling that the subject of a discussion
has changed without losing the connection to the previous
discussion: I changed the subject line to "$NEWTOPIC
(was $OLDTOPIC)" and included (or more properly "allowed
my newsreader to supply) a References header that links to
the replied-to post. I understood this to be considered
good Usenet etiquette. I guess mileage varies.

[ snip ]
 
L

lewbloch

Steve said:
... [some weird stuff] ... [ snip ]
.. the double quotes do not "list"
only the text. I think you guys call quotes "switches".

Huh? Who guys? No one I know calls them that. We call them "double
quotes".

To the sane world, they're called "double quotes".
Very possible (about different worlds), but if I had
to choose between those alternatives, "wrapping tags"
seems like a better fit than "switches" for text enclosed
in double quotes.  I don't recognize the latter usage.
<shrug>

[ snip ]
The fact you are bothered to break thread, creating
a new topic, yet fixing your nym display isn't a big
deal to you... is very interesting. But I aint got the
time ..

There's nothing whatsoever wrong with her "nym display", as you are
pleased to call it. If you really didn't have the time to pursue this
meaningless and pointless complaint of yours, you'd've never pressed
"Send". Advice you should consider.
"Break thread"?  I'm following what I understood to be the
convention for signaling that the subject of a discussion
has changed without losing the connection to the previous
discussion:  I changed the subject line to "$NEWTOPIC
(was $OLDTOPIC)" and included (or more properly "allowed
my newsreader to supply) a References header that links to
the replied-to post.  I understood this to be considered
good Usenet etiquette.  I guess mileage varies.

[ snip ]

BLM: You did the right thing. The troll to whom you responded has
some odd ideas, is all.
 
K

KitKat

On 07/07/2011 5:34 PM, Steve Erwin wrote:
[snip long, non-Java-related, but mostly civil and constructive advice
on news config to blmblm]
"Lamers" may be an exception, you could 'hear' a squeak
from the likes of "Kit-Kat", well.. maybe not in the
near future [cough] :->>>>>>>>>>>>>>>>

And here we have a gratuitous potshot buried in the middle. Aww, and
here I thought Erwin was maybe growing a social conscience. I guess not.
 
K

KitKat

btw...
You know how I got onto Seamus's tail?
Who?

The guy could not find a +h sys file on his computer.
I can still hear him wailing to this day.
"I am telling you there is no such fucking file on my
computer. It may well be on your fucking computer but
it isn't on my fucking computer and my fucking computer
works, thank you so very fucking much for your fucking
no-help!"
Yeh, true!
This from a guy with a BSc in computer science, so he
says, and a whole list of languages under his belt.
Didn't even have a CLUE about +rash

And what has this to do with Java?
nup.. sorry, got no time for the education of those who
believe a whole bunch of leaping flashing icons is
great for the networks.

Well, blmblm is gonna love you then, since reading her past history here
it's clear she hates GUIs too, but you'll be in the minority.
 
S

Steve Erwin

lewbloch said:
There's nothing whatsoever wrong with her "nym display", as you are
pleased to call it. If you really didn't have the time to pursue this
meaningless and pointless complaint of yours, you'd've never pressed
"Send". Advice you should consider.
pkb... anyone?
My point - Ms Massingill - is, it is interesting you follow this
"rule of etiquette" yet ignore basic rules of network protocol
in tX'n an unkempt (shoddy - bogan) piece of bagatelle as
your "From". Small chops (as it is) it has certainly signaled to
Paul Derbyshire (lewbloch+KitKat) you are
"ripe for the fucking with of".
However, as said, you have been informed. You make your
choice, as you will.

BLM: You did the right thing. The troll to whom you responded has
some odd ideas, is all.
http://groups.google.com/groups/sea...ject=&[email protected]&safe=off
Results 1 - 21 of about 21 forauthor:[email protected].

Hi Paul.. are you going for the high score in names
used per day?

Paul.
A troll does not upload tutorials for those quite
obviously spatially enhanced, as was admitted by
the OP..****twice****.
A troll does however single out the weakest link,
dress it up with a fine sauce, and consume it.

Your desire, Paul, is to equal the character
Hannibal Lecter in your own Usenet lifetime.
Just as zany as is that character, you - **** - will starve.
Seems to me the OP has some smarts at least.
Your responses, in both smoke-shapes remain
unattended.. bummer that<BSEG>

I note you find "lew" and "gene bloch" as equal a
challenge as I.
There is value in that, for myself.

[cough]
There is a very interesting email doing the rounds
of the Mushroom Observer mailing list.
Best you rush off and attend to that?
 
B

blmblm

pkb... anyone?

My point - Ms Massingill - is, it is interesting you follow this
"rule of etiquette" yet ignore basic rules of network protocol
in tX'n an unkempt (shoddy - bogan)

Could you try that again in something more closely resembling
standard English .... Nah, I probably get enough of the intended
meaning.
piece of bagatelle as
your "From". Small chops (as it is) it has certainly signaled to
Paul Derbyshire (lewbloch+KitKat)

Are you seriously suggesting that both of these posters are Mr.
Derbyshire in disguise? That would surprise me very much in the
case of the person who posts as Lew Bloch. I've been following
this group for several years said:
you are
"ripe for the fucking with of".

I guess it's possible, but really, didn't *I* start this particular
exchange by involving myself in the "names ending in 'a' are
feminine" subthread? foolishly, no doubt, but "yeah well".

Also, if your theory about real identities is correct, there may
be a history -- but that's all I'm going to say about that.
However, as said, you have been informed. You make your
choice, as you will.

[ snip ]
 
K

KitKat

pkb... anyone?

Hardly. Lew is one of the "respected elders" in this newsgroup, you
clueless newbie.
My point - Ms Massingill - is, it is interesting you follow this
"rule of etiquette" yet ignore basic rules of network protocol
in tX'n an unkempt (shoddy - bogan) piece of bagatelle as
your "From". Small chops (as it is) it has certainly signaled to
Paul (lewbloch+KitKat) you are "ripe for the fucking with of".

What? Now you're conflating my identity with Lew's, and some other guy's?

You really are quite mad.
Hi Paul.. are you going for the high score in names
used per day?

Talking to imaginary friends in public, if not still a single-digit age,
is generally considered a sign of severe mental illness.
 
A

Arne Vajhøj

That's not quite right. In the olden days, it's true that every object
header contained room for a lock pointer - but back then, that meant
that every header was *three* words (12 bytes), not two. Two words were
needed for the header (one for a vtable pointer, one for various other
things), and the third was for the lock.

What happened then was that a very clever chap called David Bacon, who
worked for IBM, invented a thing called a thin lock:

http://www.research.ibm.com/people/d/dfb/papers.html#Bacon98Thin

Which was subsequently improved by another clever chap called Tamiya
Onodera into a thing called a tasuki lock, which you don't hear so much
about.

The details are described quite clearly in the papers, but the upshot is
that an object is created with neither a lock nor a slot for a lock
pointer (and so only a two-word header), and the lock is allocated only
when needed, and then wired in. Some fancy footwork means that the
object doesn't need to grow a pointer when this happens; the header
remains two words, at the expense of some slight awkwardness elsewhere.
Some even fancier footwork means that if only one thread locks the
object at a time (a very common pattern), then a lock doesn't even need
to be allocated.

Remember to distinguish between Java (as in JLS and JVM spec) and
a specific Java implementation.

Arne
 
A

Arne Vajhøj

I agree with this, actually. There might be some small performance
improvement, but it would also make the locking behaviour of code more
explicit, and so clearer.

Given that Java does not allow multiple inheritance then that would
have been tough restriction.

Arne
 
A

Arne Vajhøj

I'm curious why Java designers once decided to allow every object to
be lockable (i.e. allow using lock on those).
I know, that out of such a design decision every Java object contain
lock index, i.e. new Object() results in allocation of at least 8
bytes where 4 bytes is object index and 4 bytes is lock index on 32-
bit JVM.
I think that it just inefficient waste of space, because not all the
objects requires to be lockable/waitable.

The better decision, IMHO, would be to introduce lock/wait mechanics
for only, say, the Lockable descendants.
The current approach seems to be very simple, but is the performance
penalty so small for not be taken into an account?
Eclipse uses tons of small objects and I guess that is why it consumes
so much memory while a significant part of it is never used.

What do you think of it?

For all the simple cases:

public class Foobar {
...
private Object lock = new Object();
...
public void test() {
...
synchronized(lock) {
...
}
...
}
...
}

having to use LockingObject instead of Object would have worked fine.

But in more complex scenarios where you have multiple methods modifying
multiple objects, then the only safe way is to lock on the actual
objects (obviously in a fixed order to avoid deadlocks).

Arne
 
H

Henderson

Given that Java does not allow multiple inheritance then that would
have been tough restriction.

Others suggested that Lockable could have been a marker interface with
special significance to the compiler, ala Serializable. Java allows
multiple inheritance of interfaces.
 
A

Arne Vajhøj

Others suggested that Lockable could have been a marker interface with
special significance to the compiler, ala Serializable. Java allows
multiple inheritance of interfaces.

It could be, but does that provide any space in the data structure?

Arne
 
A

Arne Vajhøj

..which is about the most annoying omission...

Well - SUN did not think so and when MS had to do .NET and C# they
did not think so.

Sure SUN and MS could be wrong, but there must be some merit to
omitting it.

Arne
 
A

Arne Vajhøj

On 7/21/2011 5:33 PM, Arne Vajhøj wrote:
...

I'm not sure how that would have worked for synchronized methods, as
distinct from synchronized blocks.

It does not.

Synchronized methods are only for the simple cases.

Arne
 
A

Arne Vajhøj

Compiler magic. Just as the compiler reacts the lack of any constructor
by generating a default constructor, it would react to the Lockable
interface by generating a field to contain the lock data.

It is possible.

I am not a big fan of that type of magic, but it is possible.

Arne
 
A

Alex Shabanov

...
Keeping in mind the difference C vs Java implementation I can only
speculate on how muchlockfunctionalitycontributes to that overhead.

BTW, if someone is still interested in the overhead:

$ANDROID_SOURCES/dalvik/vm/oo/Object.h introduces the following layout
behind the Object class:

typedef struct Object {
/* ptr to class object */
ClassObject* clazz;

/*
* A word containing either a "thin" lock or a "fat" monitor. See
* the comments in Sync.c for a description of its layout.
*/
u4 lock;
} Object;

So the memory overhead is known (and it is +4 bytes for all the
Objects no matter if they ever locked or not).

As for HotSpot JVM it is not that easy to find the distinctive layout
of the Object class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top