Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Forward progress is defined as follows: </p> <blockquote> <p>If no process is executing in its CS and there exist some processes that wish to enter their CS, then the selection of the process that will enter the CS next cannot be postponed indefinitely. </p> </blockquote> <p>The code you wrote above does not satisfy this in the case the threads are not balanced, consider the following scenario: </p> <ol> <li>P0 has entered the critical section, finished it, and set the turn to P1. </li> <li>P1 enters the section, completes it, sets the turn back to P0.</li> <li>P1 quickly completes the remainder section, and wishes to enter the critical section again. However, P0 still holds the turn.</li> <li>P0 gets stalled somewhere in its remainder section indefinitely. P1 is starved.</li> </ol> <p>In other words, this algorithm can't support a system where one of the processes runs much faster. It forces the critical section to be owned in equal turns by <code>P0 -&gt; P1 -&gt; P0 -&gt; P1 -&gt; ..</code>. For forward progress we would like to allow a scenario where it's owned for example in the following manner <code>P0 -&gt; P1 -&gt; P1 -&gt; ..</code>, and continuing with P1 while P0 isn't ready for entering again. Otherwise P1 may be starved.</p> <p><a href="http://en.wikipedia.org/wiki/Peterson%27s_algorithm" rel="nofollow">Petersons' algorithm</a> fixes this by adding flags to indicate when a thread is <strong>ready</strong> to enter the critical section, on top of the turn-based fairness like you have. This guarantees that no one is stalled by the other thread inefficiency, and that no one can enter multiple times in a row unless the other permits it to.</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