Advanced | Help | Encyclopedia
Directory


Peterson's algorithm

Peterson's algorithm is a concurrent programming algorithm for mutual exclusion that allows two processes to share a single-use resource without conflict, using only shared memory for communication.

The following is wikicode, a proposed pseudocode for use in many articles.

 f0   := 0
 f1   := 0
 last := 0

 p0: f0 := 1                        p1: f1 := 1
     last := 0                          last := 1
     do {                               do {
     } until f1 = 0 or last ≠ 0         } until f0 = 0 or last ≠ 1

     // critical section                // critical section 

     f0 := 0                            f1 := 0

See also

Dekker's algorithm








Links: Addme | Keyword Research | Paid Inclusion | Femail | Software | Completive Intelligence

Add URL | About Slider | FREE Slider Toolbar - Simply Amazing
Copyright © 2000-2008 Slider.com. All rights reserved.
Content is distributed under the GNU Free Documentation License.