Dining philosophers – The 4th solution

22Sep09

*** BLOG HAS MOVED ***

Dear visitor,

This blog has MOVED entirely to: http://blog.bestinclass.dk

This site will no longer be updated so please change your bookmarks and RSS subscriptions accordingly.

Thank you all for your time and comments,

Lau

*** BLOG HAS MOVED ***

About these ads


5 Responses to “Dining philosophers – The 4th solution”

  1. 1 Salvador Fuentes

    A bit off topic, but I was wondering and hoping if you would consider a “Haskell Vs Clojure” piece. I understand that there aren’t any mature Haskell compilers that target the JVM, but I think it would be a good and important discussion about these functional languages. I’m just starting my adventures with Clojure and I have found your blog very enlightening by the way. Looking forward to many more posts.

  2. 2 bestinclass

    @Salvador. Thank you for your comment! I’ll have a look at Haskell and see if that’ll make for a good comparison, i hadn’t thought of that before.

  3. One thing that is not clear to me, is how a philosopher can see that the fork he is waiting for, has been released? With STM’s you can use the retry primitive for that, but afaik Clojure doesn’t support that to prevent read tracking.

    PS:
    This is an example of the dining philosophers problem in Multiverse:
    http://code.google.com/p/multiverse/source/browse/trunk/src/test/org/multiverse/integrationtests/DiningPhilosophersLongTest.java

  4. 4 bestinclass

    @pveentjer: To keep it simple, the philosopher looks to see if his forks are available, if not the thread restarts, and he might look again or decide to think. This still is helpful in showing how to avoid a lock gone bad situation, but if you wanted a more ‘too to the spirit of the problem’ solution, you should change the when to an if statement, and call add-watcher on the fork.


  1. 1 Twitter Trackbacks for Dining philosophers – The 4th solution « Best In Class – The Blog [bestinclass.wordpress.com] on Topsy.com

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: