Thread View: comp.lang.java.programmer
3 messages
3 total messages
Started by Alexander Anderson
Fri, 04 Jul 1997 00:00
The "Dining Philosophers" problem
Author: Alexander Anderson
Date: Fri, 04 Jul 1997 00:00
Date: Fri, 04 Jul 1997 00:00
71 lines
3102 bytes
3102 bytes
Dear Programmer,
I'm trying to understand what's involved in how threads and thread
synchronization is implemented in the JVM.
Sunsoft's "The Java Virtual Machine" (ISBN ISBN 0-201-63452-X) is
unreadable. The O'Reilly "Java Virtual Machine" (ISBN 1-56592-194-1) is
good, but fizzles out completely about threads: it's Threads chapter is
just 3 pages.
Bill "Under The Hood" Venners has written a book "Inside the Java
Virtual Machine" (ISBN 0-07-913248-0) but it's not in print yet:
http://www.artima.com/insidejvm/blurb.shtml
In my investigating, I knocked up a couple of little text-mode apps
to spark discussion on threads on behalf of a group implementating the
JVM for Psion 3 handhelds.
The source and documentation is at:
http://www.mdx.ac.uk/~tr033/source_code/JAVA/PSION-JAVA/Philosophers.html
This is a pretty neat, fairly compact example of a solution to the
main "Dining Philosophers" problem (I think!). It doesn't concern
itself with "starvation" at all.
I would like to have it confirmed whether this solution can deadlock
or not; and what is a better, clearer, more succinct solution. In
particular, can I dispense with the Chopsticks somehow and get the
philosophers to synchronise on themselves? I have a feeling there's
something impossible about that though.
This is completely unrelated to my original aim, but where do I find
out about proving properties of parallel systems? It really bugs me
that I only have a gut feeling that it's working.
Also, in Chopstick.java, I have a wait() that's guarded by an 'if'
not a 'while'. I am uneasy about this: I got to the current solution
by magic, it felt like. How can I arrange for it to be guarded by a while
loop?
Thanks in advance,
Sandy
/* Correct my address in any reply, or it'll be treated as spam:
--
// Alexander Anderson <DELETE_THIS.sandy@almide.demon.co.uk>
// Home Fone +44 (0) 171-794-4543
// London, UK http://www.almide.demon.co.uk/
// PGP print C6 8C 55 F2 77 7B 99 9B 14 77 66 F5 B8 74 CF 12
*/
Re: The "Dining Philosophers" problem
Author: Alec Cawley
Date: Sun, 06 Jul 1997 00:00
Date: Sun, 06 Jul 1997 00:00
28 lines
2089 bytes
2089 bytes
In article <8EikmEAmxIvzEwqa@almide.demon.co.uk>, Alexander Anderson <DELETE_THIS.sandy@almide.demon.co.uk> writes > This is completely unrelated to my original aim, but where do I find >out about proving properties of parallel systems? It really bugs me >that I only have a gut feeling that it's working. May I suggest asking this question on comp.sys.transputer? There are a lot of people there interested in parallel systems. There was a recent post (if your newsserver goes back 14 days, it will probably still have it, and it is not a high traffic group) about people working on adding "theoretically pure" parallelism to Java - they reckoned that Java's intrinsic parallelism was very impure (I pass no comment). Taking your thread title, one of their examples came from "modelling" the behaviour in the canteen during a worksop, by which one person proved empirically that a certain algorithm could lead to starvation, if not deadlock. The problem was solved by human override by hungry participants of the algorithm. If the post is not there, hunt at University of Kent at Cantutrbury (...ukc.ac.uk) - they are a centre of info on this sort of thing; many of the web pages in their posts were to this. -- Alec Cawley Newbury Berks, UK
Re: The "Dining Philosophers" problem
Author: Alexander Anderson
Date: Mon, 07 Jul 1997 00:00
Date: Mon, 07 Jul 1997 00:00
50 lines
2680 bytes
2680 bytes
In article <CI0JXHAqLCwzEw1e@cawley.demon.co.uk>, Alec Cawley
<alec@cawley.demon.co.uk> writes
>May I suggest asking this question on comp.sys.transputer? There are a
>lot of people there interested in parallel systems. There was a recent
>post (if your newsserver goes back 14 days, it will probably still have
>it, and it is not a high traffic group) about people working on adding
>"theoretically pure" parallelism to Java - they reckoned that Java's
>intrinsic parallelism was very impure (I pass no comment).
I didn't know there _was_ a c.s.transputer. I'm only subscribed to
a mailing list which is very low traffic and always talking about wierd
things to do with KROK and SPOC.
I am a huge fan of Occam, the transputer, and by proxy, Tony Hoare.
Dahell with whether it's "theoretically pure": Occam is an absolute
delight to program in. Very, very elegant solutions that seem to come
straight from the data flow diagrams you doodled the day before.
I always silently disliked the bloated accountancy feel of Ada, and
I really became a convert to "less is more" when I learnt to use Occam.
Java and Ada in comparison to Occam is really plodding stuff,
parallelilly.
I will subscribe to c.s.transputer at once. In fact I've already
done it. And it's not moderated, neither!
Regards and thanks,
Sandy
/* Correct my address in any reply, or it'll be treated as spam:
--
// Alexander Anderson <DELETE_THIS.sandy@almide.demon.co.uk>
// Home Fone +44 (0) 171-794-4543
// London, UK http://www.almide.demon.co.uk/
// PGP print C6 8C 55 F2 77 7B 99 9B 14 77 66 F5 B8 74 CF 12
*/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads