Más sobre el algoritmo de Peterson Sistemas Operativos 2.0 UNITEC, Campus Tegucigalpa Egdares Futch H. Basado en Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze
Solución para 2 procesos (Peterson - 1981) Shared variables of algorithms 1 and 2 - initialization: int flag[2]; flag[0] = flag[1] = 0; int turn = 0; Thread T i do { flag[i] = 1; turn = j; while ((flag[j] == 1) && turn == j) ; critical section flag[i] = 0; remainder section } while (1); Solves the critical-section problem for two threads.
Solución para  N  procesos (Hofri - 1990) N procesos, T 1  a T N-1 , N niveles/salas de espera: int level[n]; int turn[n-1]; // primer proceso=1 Thread T i do { for (k = 1 ; k < n ; k++) {   level[i] = k;   turn[k] = i;   foreach (t != i)   if (level[t] >= k && turn[k] == i) ; }  level[i] = n;   critical section   level[i] = 0;   remainder section } while (1);

Más sobre el Algoritmo de Peterson

  • 1.
    Más sobre elalgoritmo de Peterson Sistemas Operativos 2.0 UNITEC, Campus Tegucigalpa Egdares Futch H. Basado en Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas Polze
  • 2.
    Solución para 2procesos (Peterson - 1981) Shared variables of algorithms 1 and 2 - initialization: int flag[2]; flag[0] = flag[1] = 0; int turn = 0; Thread T i do { flag[i] = 1; turn = j; while ((flag[j] == 1) && turn == j) ; critical section flag[i] = 0; remainder section } while (1); Solves the critical-section problem for two threads.
  • 3.
    Solución para N procesos (Hofri - 1990) N procesos, T 1 a T N-1 , N niveles/salas de espera: int level[n]; int turn[n-1]; // primer proceso=1 Thread T i do { for (k = 1 ; k < n ; k++) { level[i] = k; turn[k] = i; foreach (t != i) if (level[t] >= k && turn[k] == i) ; } level[i] = n; critical section level[i] = 0; remainder section } while (1);