SlideShare a Scribd company logo
Trace the Dining Philosopher problem and write the flow of states using table below. If
philosophers 2, 3 and 5 try to eat. Write the states of all philosophers whenever there is a change
in
one philosopher state.
Semaphore me= 1; /* for mutual exclusion */
Semaphore s[5], all initially 0; /* for synchronization */
pflag[5]: {THINK, HUNGRY, EAT}, initially THINK; /* philosopher flag */
procedure philosopher(i) //starts here
{
while TRUE do
{
THINKING;
take_chopsticks(i);
EATING;
drop_chopsticks(i);
}
}
procedure take_chopsticks(i)
{
P(me); /* critical section */
pflag[i] = HUNGRY;
test[i];
V(me); /* end critical section */
P(s[i]) /* Eat if enabled */
}
void test(i) /* Let phil[i] eat, if waiting */
{
if ( pflag[i] == HUNGRY && pflag[i-1] != EAT && pflag[i+1] != EAT)then
{
pflag[i] = EAT;
V(s[i])
}
}
void drop_chopsticks(int i)
{
P(me); /* critical section */
pflag[i]=THINKING;
test(i-1); /* Let phil. on left eat if possible */
test(i+1); /* Let phil. on right eat if possible */
V(me); /* up critical section */
}
Write the change in state of philosophers [T,E,H]. Initially all are in the thinking state [T].

More Related Content

More from abhisheksharmasre

Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdfAf if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
abhisheksharmasre
 
Question 1 MiniList collection 20 marks In this question .pdf
Question 1 MiniList collection 20 marks In this question .pdfQuestion 1 MiniList collection 20 marks In this question .pdf
Question 1 MiniList collection 20 marks In this question .pdf
abhisheksharmasre
 
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdfBayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
abhisheksharmasre
 
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdfBir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
abhisheksharmasre
 
Angela is an artist who puts together an exhibit of modern a.pdf
Angela is an artist who puts together an exhibit of modern a.pdfAngela is an artist who puts together an exhibit of modern a.pdf
Angela is an artist who puts together an exhibit of modern a.pdf
abhisheksharmasre
 
Describe two detection methods for exoplanets other than the.pdf
Describe two detection methods for exoplanets other than the.pdfDescribe two detection methods for exoplanets other than the.pdf
Describe two detection methods for exoplanets other than the.pdf
abhisheksharmasre
 
Case Study WGM employs many employees in several departments.pdf
Case Study WGM employs many employees in several departments.pdfCase Study WGM employs many employees in several departments.pdf
Case Study WGM employs many employees in several departments.pdf
abhisheksharmasre
 
3 1 point Let PA03PB04PBA01 Find PAB.pdf
3 1 point Let PA03PB04PBA01 Find PAB.pdf3 1 point Let PA03PB04PBA01 Find PAB.pdf
3 1 point Let PA03PB04PBA01 Find PAB.pdf
abhisheksharmasre
 
Cul de las siguientes describe MEJOR las caractersticas d.pdf
Cul de las siguientes describe MEJOR las caractersticas d.pdfCul de las siguientes describe MEJOR las caractersticas d.pdf
Cul de las siguientes describe MEJOR las caractersticas d.pdf
abhisheksharmasre
 
1 How to calculate COGS and Ending Inventory using either t.pdf
1 How to calculate COGS and Ending Inventory using either t.pdf1 How to calculate COGS and Ending Inventory using either t.pdf
1 How to calculate COGS and Ending Inventory using either t.pdf
abhisheksharmasre
 
PLEASE HELP Refer to the HarrisTodaro migration model As.pdf
PLEASE HELP   Refer to the HarrisTodaro migration model As.pdfPLEASE HELP   Refer to the HarrisTodaro migration model As.pdf
PLEASE HELP Refer to the HarrisTodaro migration model As.pdf
abhisheksharmasre
 
prepare a chart Part 1 Stakeholder Register Choose a proj.pdf
prepare a chart  Part 1  Stakeholder Register Choose a proj.pdfprepare a chart  Part 1  Stakeholder Register Choose a proj.pdf
prepare a chart Part 1 Stakeholder Register Choose a proj.pdf
abhisheksharmasre
 
1 Explain the role of each of the following in HIV infectio.pdf
1 Explain the role of each of the following in HIV infectio.pdf1 Explain the role of each of the following in HIV infectio.pdf
1 Explain the role of each of the following in HIV infectio.pdf
abhisheksharmasre
 
1 As you work towards a final transaction name three items.pdf
1 As you work towards a final transaction name three items.pdf1 As you work towards a final transaction name three items.pdf
1 As you work towards a final transaction name three items.pdf
abhisheksharmasre
 
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdfPERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
abhisheksharmasre
 
Please write it in C not python .pdf
Please write it in C not python .pdfPlease write it in C not python .pdf
Please write it in C not python .pdf
abhisheksharmasre
 
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdfMary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
abhisheksharmasre
 
If a profit maximizing monopolist operates where P1 and th.pdf
If a profit maximizing monopolist operates where P1 and th.pdfIf a profit maximizing monopolist operates where P1 and th.pdf
If a profit maximizing monopolist operates where P1 and th.pdf
abhisheksharmasre
 
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdffy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
abhisheksharmasre
 
On the basis of the financial ratios and benchmarking inform.pdf
On the basis of the financial ratios and benchmarking inform.pdfOn the basis of the financial ratios and benchmarking inform.pdf
On the basis of the financial ratios and benchmarking inform.pdf
abhisheksharmasre
 

More from abhisheksharmasre (20)

Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdfAf if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
Af if be abint Quentien 18 Quevioni Guantion 29The secon.pdf
 
Question 1 MiniList collection 20 marks In this question .pdf
Question 1 MiniList collection 20 marks In this question .pdfQuestion 1 MiniList collection 20 marks In this question .pdf
Question 1 MiniList collection 20 marks In this question .pdf
 
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdfBayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
Bayan Mahta Amiri uzun yllara dayanan deneyime sahip bir Se.pdf
 
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdfBir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
Bir stma paraziti plazmodyum tr bir krmz kan hcresini i.pdf
 
Angela is an artist who puts together an exhibit of modern a.pdf
Angela is an artist who puts together an exhibit of modern a.pdfAngela is an artist who puts together an exhibit of modern a.pdf
Angela is an artist who puts together an exhibit of modern a.pdf
 
Describe two detection methods for exoplanets other than the.pdf
Describe two detection methods for exoplanets other than the.pdfDescribe two detection methods for exoplanets other than the.pdf
Describe two detection methods for exoplanets other than the.pdf
 
Case Study WGM employs many employees in several departments.pdf
Case Study WGM employs many employees in several departments.pdfCase Study WGM employs many employees in several departments.pdf
Case Study WGM employs many employees in several departments.pdf
 
3 1 point Let PA03PB04PBA01 Find PAB.pdf
3 1 point Let PA03PB04PBA01 Find PAB.pdf3 1 point Let PA03PB04PBA01 Find PAB.pdf
3 1 point Let PA03PB04PBA01 Find PAB.pdf
 
Cul de las siguientes describe MEJOR las caractersticas d.pdf
Cul de las siguientes describe MEJOR las caractersticas d.pdfCul de las siguientes describe MEJOR las caractersticas d.pdf
Cul de las siguientes describe MEJOR las caractersticas d.pdf
 
1 How to calculate COGS and Ending Inventory using either t.pdf
1 How to calculate COGS and Ending Inventory using either t.pdf1 How to calculate COGS and Ending Inventory using either t.pdf
1 How to calculate COGS and Ending Inventory using either t.pdf
 
PLEASE HELP Refer to the HarrisTodaro migration model As.pdf
PLEASE HELP   Refer to the HarrisTodaro migration model As.pdfPLEASE HELP   Refer to the HarrisTodaro migration model As.pdf
PLEASE HELP Refer to the HarrisTodaro migration model As.pdf
 
prepare a chart Part 1 Stakeholder Register Choose a proj.pdf
prepare a chart  Part 1  Stakeholder Register Choose a proj.pdfprepare a chart  Part 1  Stakeholder Register Choose a proj.pdf
prepare a chart Part 1 Stakeholder Register Choose a proj.pdf
 
1 Explain the role of each of the following in HIV infectio.pdf
1 Explain the role of each of the following in HIV infectio.pdf1 Explain the role of each of the following in HIV infectio.pdf
1 Explain the role of each of the following in HIV infectio.pdf
 
1 As you work towards a final transaction name three items.pdf
1 As you work towards a final transaction name three items.pdf1 As you work towards a final transaction name three items.pdf
1 As you work towards a final transaction name three items.pdf
 
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdfPERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
PERT ve CPM ile ilgili olarak aadaki ifadelerden hangisi dor.pdf
 
Please write it in C not python .pdf
Please write it in C not python .pdfPlease write it in C not python .pdf
Please write it in C not python .pdf
 
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdfMary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
Mary Lou eitim tasarruf hesabndan 8000 lk bir datm ald v.pdf
 
If a profit maximizing monopolist operates where P1 and th.pdf
If a profit maximizing monopolist operates where P1 and th.pdfIf a profit maximizing monopolist operates where P1 and th.pdf
If a profit maximizing monopolist operates where P1 and th.pdf
 
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdffy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
fy1 y2 y3 5 Let Y1Y2 and Y3 be three continuous rando.pdf
 
On the basis of the financial ratios and benchmarking inform.pdf
On the basis of the financial ratios and benchmarking inform.pdfOn the basis of the financial ratios and benchmarking inform.pdf
On the basis of the financial ratios and benchmarking inform.pdf
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 

Trace the Dining Philosopher problem and write the flow of s.pdf

  • 1. Trace the Dining Philosopher problem and write the flow of states using table below. If philosophers 2, 3 and 5 try to eat. Write the states of all philosophers whenever there is a change in one philosopher state. Semaphore me= 1; /* for mutual exclusion */ Semaphore s[5], all initially 0; /* for synchronization */ pflag[5]: {THINK, HUNGRY, EAT}, initially THINK; /* philosopher flag */ procedure philosopher(i) //starts here { while TRUE do { THINKING; take_chopsticks(i); EATING; drop_chopsticks(i); } } procedure take_chopsticks(i) { P(me); /* critical section */ pflag[i] = HUNGRY; test[i]; V(me); /* end critical section */ P(s[i]) /* Eat if enabled */ } void test(i) /* Let phil[i] eat, if waiting */ { if ( pflag[i] == HUNGRY && pflag[i-1] != EAT && pflag[i+1] != EAT)then { pflag[i] = EAT; V(s[i]) } } void drop_chopsticks(int i) { P(me); /* critical section */ pflag[i]=THINKING; test(i-1); /* Let phil. on left eat if possible */ test(i+1); /* Let phil. on right eat if possible */
  • 2. V(me); /* up critical section */ } Write the change in state of philosophers [T,E,H]. Initially all are in the thinking state [T].