🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.programmer
Article #212

The "Dining Philosophers" problem

#212
From: Alexander Anderson
Date: Fri, 04 Jul 1997 00:00
71 lines
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
*/
Technical Details
Message-ID: <8EikmEAmxIvzEwqa@almide.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10a146,9783db5148d812ba,start
X-Google-Attributes: gid10a146,public
X-Google-Thread: f9199,9783db5148d812ba,start
X-Google-Attributes: gidf9199,public
X-Google-Thread: 10bb9b,9783db5148d812ba,start
X-Google-Attributes: gid10bb9b,public
X-Google-Thread: f9e8f,9783db5148d812ba,start
X-Google-Attributes: gidf9e8f,public
From: Alexander Anderson <DELETE_THIS.sandy@almide.demon.co.uk>
Subject: The "Dining Philosophers" problem
Date: 1997/07/04
Message-ID: <8EikmEAmxIvzEwqa@almide.demon.co.uk>
X-Deja-AN: 254451563
Distribution: world
X-NNTP-Posting-Host: almide.demon.co.uk [158.152.137.110]
Organization: ALMA Services
Newsgroups: comp.lang.java.programmer,comp.lang.java.machine,comp.sys.psion.programmer,aus.computers.parallel