answersLogoWhite

0

while(1) { // thread i (0 <= i < n)

for (j=1 ; j<n ; j++) {

flag[i]=j;

last[j]=i;

for (k=0 ; k<n ; k++) {

if (k==i) continue;

while (flag[k]>=flag[i] && last[j]==i) {

sleep(random());

}

}

}

// critical section

...

// end of critical section

flag[i]=0;

// not critical section

...

// end of not critical section

}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin

Add your answer:

Earn +20 pts
Q: Peterson algorigthm with n process
Write your answer...
Submit
Still have questions?
magnify glass
imp