La solution pour 2 processus
int turn;
int interested[2];
void entrer_region(int processus)
{
int other;
other=1-processus;
interested[processus]=true;
turn=processus;
while (turn==processus && interested[other]==ture)
{ /*LOOP*/ }
}
Ma solution pour N processus
int turn;
int interested[N];
void entrer_region()
{
for (i=0; i<N;i++)
{
if (interested[i]==true)
processus=i;
turn=processus;
}
for (j=0;j<N && j!=i; j++)
{
if (interested[j]==ture)
{ /*LOOP*/ }
}
EST CE QUE C JUSTE ?????
Partager