/* Definición de variables compartidas */
shared int bandera[2] = {0,0};
shared int turno = 0;
while (cierto)
{
bandera[proc_id] = cierto;
while (bandera[1-proc_id] == cierto)
{
if (turno == 1-proc_id)
{
bandera[proc_id] = 0;
while (turno == (1-proc_id)) /* espera a que sea su turno de intentar */;
bandera[proc_id] = 1;
}
/* Sección crítica */
turno = 1-proc_id; /* es el turno del otro proceso */
bandera[proc_id] = 0;
/* Sección no crítica */
}
}
más o menos esto es lo que debes de hacer.... mejóralo tú....
Este lo tome de la siguiente dirección:
http://es.wikipedia.org/wiki/Algoritmo_de_Dekker
Si quieres uno completo visita:
http://www.infor.uva.es/~cllamas/concurr/pract97/smvillal/programa.html