Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem is that you've got three modules: <code>dinner</code>, <code>eater</code>, and <code>chopstick</code>, but try to call <code>philospher:start</code> in your <code>dinner:init/0</code> function. Try <code>eater:start</code> instead.</p> <p>The second problem is the order of module and function name when generating random numbers; replace <code>uniform:random</code> with <code>random:uniform</code> in your <code>eater.erl</code>:</p> <pre><code>1&gt; dinner:start(). &lt;0.35.0&gt; Confucios received a chopstick Confucios received a chopstick Confucios started eating Confucios put back two chopsticks Confucios received a chopstick Confucios received a chopstick Confucios started eating Confucios put back two chopsticks Confucios received a chopstick Confucios received a chopstick Confucios started eating Confucios put back two chopsticks Confucios received a chopstick Confucios received a chopstick Confucios started eating Confucios put back two chopsticks Confucios received a chopstick Confucios received a chopstick Confucios started eating Confucios put back two chopsticks Avicenna received a chopstick Avicenna received a chopstick Avicenna started eating ... </code></pre> <p>This pretty quickly shows the third problem -- something we should have spotted from the first error report -- that the eaters aren't actually in their own processes. So edit <code>eater.erl</code> so that the <code>start()</code> function reads:</p> <pre><code>start(Hungry, Right, Left, Name, Ctrl) -&gt; spawn_link(fun() -&gt; dream(Hungry, Right, Left, Name, Ctrl) end). </code></pre> <p>Now it works as intended:</p> <pre><code>1&gt; dinner:start(). &lt;0.35.0&gt; Confucios received a chopstick Plato received a chopstick Confucios received a chopstick Confucios started eating Descartes received a chopstick Kant received a chopstick Confucios put back two chopsticks Avicenna received a chopstick ... </code></pre> <p>Thanks. This was good fun.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload