SlideShare a Scribd company logo
1 of 3
Download to read offline
DATA:
condition can_eat[NUM_PHILS];
enum states state[NUM_PHILS-1];
int index;
INITIALIZATION:
for (index=0; index<NUM_PHILS; index++)
MONITOR PROCEDURES:
/* request the proper to pickup chopsticks and eat */
entry void pickup(int mynum) are not feeding, proceed */
if ((state[mynum-1 mod NUM_PHILS] != EATING) &&
(state [mynum+1 mod NUM_PHILS] != EATING))
/* otherwise await them */
else able to eat currently */
state[mynum] = EATING;
}
}
/* announce that we're finished, provide others an opportunity */
entry void putdown(int mynum) {
/* announce that we're done */
state[mynum] = THINKING;
/* provide left (lower) neighbor an opportunity to eat */
if ((state [mynum-1 mod NUM_PHILS] == HUNGRY) &&
(state [mynum-2 mod NUM_PHILS] != EATING))
/* provide right (higher) neighbor an opportunity to eat */
if ((state [mynum+1 mod NUM_PHILS] == HUNGRY) &&
(state [mynum+2 mod NUM_PHILS] != EATING))
}
PHILOSOPHER:
/* resolve our id, then repeat forever */
American state = get_my_id();
whereas (TRUE) lie with all once more ... */
think();
pickup(me);
eat();
putdown(me);
}
Solution
DATA:
condition can_eat[NUM_PHILS];
enum states state[NUM_PHILS-1];
int index;
INITIALIZATION:
for (index=0; index<NUM_PHILS; index++)
MONITOR PROCEDURES:
/* request the proper to pickup chopsticks and eat */
entry void pickup(int mynum) are not feeding, proceed */
if ((state[mynum-1 mod NUM_PHILS] != EATING) &&
(state [mynum+1 mod NUM_PHILS] != EATING))
/* otherwise await them */
else able to eat currently */
state[mynum] = EATING;
}
}
/* announce that we're finished, provide others an opportunity */
entry void putdown(int mynum) {
/* announce that we're done */
state[mynum] = THINKING;
/* provide left (lower) neighbor an opportunity to eat */
if ((state [mynum-1 mod NUM_PHILS] == HUNGRY) &&
(state [mynum-2 mod NUM_PHILS] != EATING))
/* provide right (higher) neighbor an opportunity to eat */
if ((state [mynum+1 mod NUM_PHILS] == HUNGRY) &&
(state [mynum+2 mod NUM_PHILS] != EATING))
}
PHILOSOPHER:
/* resolve our id, then repeat forever */
American state = get_my_id();
whereas (TRUE) lie with all once more ... */
think();
pickup(me);
eat();
putdown(me);
}

More Related Content

More from ankurbhargava44

The common ion effect is responsible for the reduction in the solubi.pdf
The common ion effect is responsible for the reduction in the solubi.pdfThe common ion effect is responsible for the reduction in the solubi.pdf
The common ion effect is responsible for the reduction in the solubi.pdf
ankurbhargava44
 
The DNA matching is carried out by comparing the DNA sequences of th.pdf
The DNA matching is carried out by comparing the DNA sequences of th.pdfThe DNA matching is carried out by comparing the DNA sequences of th.pdf
The DNA matching is carried out by comparing the DNA sequences of th.pdf
ankurbhargava44
 
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdf
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdfStormwater BMPs for urban useStormwater runoff is the water flowi.pdf
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdf
ankurbhargava44
 
Rules generally followed are1. Using existing terminology wheneve.pdf
Rules generally followed are1. Using existing terminology wheneve.pdfRules generally followed are1. Using existing terminology wheneve.pdf
Rules generally followed are1. Using existing terminology wheneve.pdf
ankurbhargava44
 
in my view nationwide health information network makes sure that hea.pdf
in my view nationwide health information network makes sure that hea.pdfin my view nationwide health information network makes sure that hea.pdf
in my view nationwide health information network makes sure that hea.pdf
ankurbhargava44
 
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdfFactors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
ankurbhargava44
 
Answerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdfAnswerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdf
ankurbhargava44
 

More from ankurbhargava44 (20)

The common ion effect is responsible for the reduction in the solubi.pdf
The common ion effect is responsible for the reduction in the solubi.pdfThe common ion effect is responsible for the reduction in the solubi.pdf
The common ion effect is responsible for the reduction in the solubi.pdf
 
The DNA matching is carried out by comparing the DNA sequences of th.pdf
The DNA matching is carried out by comparing the DNA sequences of th.pdfThe DNA matching is carried out by comparing the DNA sequences of th.pdf
The DNA matching is carried out by comparing the DNA sequences of th.pdf
 
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdf
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdfStormwater BMPs for urban useStormwater runoff is the water flowi.pdf
Stormwater BMPs for urban useStormwater runoff is the water flowi.pdf
 
SolutionIt is given that time slots are random and independent. S.pdf
SolutionIt is given that time slots are random and independent. S.pdfSolutionIt is given that time slots are random and independent. S.pdf
SolutionIt is given that time slots are random and independent. S.pdf
 
Solution 1United states treasury bonds pays semi annual interest .pdf
Solution 1United states treasury bonds pays semi annual interest .pdfSolution 1United states treasury bonds pays semi annual interest .pdf
Solution 1United states treasury bonds pays semi annual interest .pdf
 
since you have 2 mols of O3 going to 3O2 you divide your delta H by .pdf
since you have 2 mols of O3 going to 3O2 you divide your delta H by .pdfsince you have 2 mols of O3 going to 3O2 you divide your delta H by .pdf
since you have 2 mols of O3 going to 3O2 you divide your delta H by .pdf
 
Rules generally followed are1. Using existing terminology wheneve.pdf
Rules generally followed are1. Using existing terminology wheneve.pdfRules generally followed are1. Using existing terminology wheneve.pdf
Rules generally followed are1. Using existing terminology wheneve.pdf
 
Arranging in ascending orderMedian =(8.1+9.1)2 = 8.6Solution.pdf
Arranging in ascending orderMedian =(8.1+9.1)2 = 8.6Solution.pdfArranging in ascending orderMedian =(8.1+9.1)2 = 8.6Solution.pdf
Arranging in ascending orderMedian =(8.1+9.1)2 = 8.6Solution.pdf
 
Please find my code.import java.util.Arrays;import java.util.Ran.pdf
Please find my code.import java.util.Arrays;import java.util.Ran.pdfPlease find my code.import java.util.Arrays;import java.util.Ran.pdf
Please find my code.import java.util.Arrays;import java.util.Ran.pdf
 
only similarity- Mean, median and mode are all different terms of ce.pdf
only similarity- Mean, median and mode are all different terms of ce.pdfonly similarity- Mean, median and mode are all different terms of ce.pdf
only similarity- Mean, median and mode are all different terms of ce.pdf
 
All of the above .pdf
                     All of the above                                 .pdf                     All of the above                                 .pdf
All of the above .pdf
 
Actually [ NH3 ] 2 causes redness in a solution .pdf
                     Actually [ NH3 ] 2 causes redness in a solution  .pdf                     Actually [ NH3 ] 2 causes redness in a solution  .pdf
Actually [ NH3 ] 2 causes redness in a solution .pdf
 
Let the length be x unitsWidth of a rectangle measure one-fourth l.pdf
Let the length be x unitsWidth of a rectangle measure one-fourth l.pdfLet the length be x unitsWidth of a rectangle measure one-fourth l.pdf
Let the length be x unitsWidth of a rectangle measure one-fourth l.pdf
 
legally considered as equity in the firm typically applies to common.pdf
legally considered as equity in the firm typically applies to common.pdflegally considered as equity in the firm typically applies to common.pdf
legally considered as equity in the firm typically applies to common.pdf
 
in my view nationwide health information network makes sure that hea.pdf
in my view nationwide health information network makes sure that hea.pdfin my view nationwide health information network makes sure that hea.pdf
in my view nationwide health information network makes sure that hea.pdf
 
Filopodia are thin projections with parallel bundles of microfilamen.pdf
Filopodia are thin projections with parallel bundles of microfilamen.pdfFilopodia are thin projections with parallel bundles of microfilamen.pdf
Filopodia are thin projections with parallel bundles of microfilamen.pdf
 
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdfFactors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
Factors in Judging ReasonablenessThe Internal Revenue Manual secti.pdf
 
A temporary relief but it increases the blood pre.pdf
                     A temporary relief but it increases the blood pre.pdf                     A temporary relief but it increases the blood pre.pdf
A temporary relief but it increases the blood pre.pdf
 
c. 1.28Solutionc. 1.28.pdf
c. 1.28Solutionc. 1.28.pdfc. 1.28Solutionc. 1.28.pdf
c. 1.28Solutionc. 1.28.pdf
 
Answerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdfAnswerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdf
 

Recently uploaded

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 

DATAcondition can_eat[NUM_PHILS]; enum states state[NUM_PHILS-1.pdf

  • 1. DATA: condition can_eat[NUM_PHILS]; enum states state[NUM_PHILS-1]; int index; INITIALIZATION: for (index=0; index<NUM_PHILS; index++) MONITOR PROCEDURES: /* request the proper to pickup chopsticks and eat */ entry void pickup(int mynum) are not feeding, proceed */ if ((state[mynum-1 mod NUM_PHILS] != EATING) && (state [mynum+1 mod NUM_PHILS] != EATING)) /* otherwise await them */ else able to eat currently */ state[mynum] = EATING; } } /* announce that we're finished, provide others an opportunity */ entry void putdown(int mynum) { /* announce that we're done */ state[mynum] = THINKING; /* provide left (lower) neighbor an opportunity to eat */ if ((state [mynum-1 mod NUM_PHILS] == HUNGRY) && (state [mynum-2 mod NUM_PHILS] != EATING)) /* provide right (higher) neighbor an opportunity to eat */ if ((state [mynum+1 mod NUM_PHILS] == HUNGRY) && (state [mynum+2 mod NUM_PHILS] != EATING)) } PHILOSOPHER: /* resolve our id, then repeat forever */ American state = get_my_id(); whereas (TRUE) lie with all once more ... */ think(); pickup(me); eat(); putdown(me);
  • 2. } Solution DATA: condition can_eat[NUM_PHILS]; enum states state[NUM_PHILS-1]; int index; INITIALIZATION: for (index=0; index<NUM_PHILS; index++) MONITOR PROCEDURES: /* request the proper to pickup chopsticks and eat */ entry void pickup(int mynum) are not feeding, proceed */ if ((state[mynum-1 mod NUM_PHILS] != EATING) && (state [mynum+1 mod NUM_PHILS] != EATING)) /* otherwise await them */ else able to eat currently */ state[mynum] = EATING; } } /* announce that we're finished, provide others an opportunity */ entry void putdown(int mynum) { /* announce that we're done */ state[mynum] = THINKING; /* provide left (lower) neighbor an opportunity to eat */ if ((state [mynum-1 mod NUM_PHILS] == HUNGRY) && (state [mynum-2 mod NUM_PHILS] != EATING)) /* provide right (higher) neighbor an opportunity to eat */ if ((state [mynum+1 mod NUM_PHILS] == HUNGRY) && (state [mynum+2 mod NUM_PHILS] != EATING)) } PHILOSOPHER: /* resolve our id, then repeat forever */ American state = get_my_id(); whereas (TRUE) lie with all once more ... */ think();