I am going through a code example in my textbook (dining philosophers problem) and in the main method, right before the return 0; statement, there is the block of code I've included below. This loop is supposed to create the philosophers each as a concurrent forked process. This means that each philosopher executes philosopher(i).
However, since right after the if statement, there follows a break, doesn't that mean only the first philosopher (i = 0) is created?
for (i = 0; i < N - 1; ++i)
if (fork() == 0)
break;
philosopher(i) ;
Aucun commentaire:
Enregistrer un commentaire