Question: C, Unix/Linux Multithreading, Pthreads, Process Synchronization The famous Dining Philosophers problem consists of an eating-thinking cycle. An entrepreneur who knows this has opened a place

C, Unix/Linux Multithreading, Pthreads, Process Synchronization

The famous Dining Philosophers problem consists of an eating-thinking cycle. An entrepreneur who knows this has opened a place called DinoPhilo. There are 10 round tables in the venue. Each table seats 8 people. Customer acceptance is in the form of accepting a philosopher group of 80 people, and each group is taken to exactly one table. When the place is full, the incoming groups are put on hold outside (the place has 80 people). The group that eats its food gets up en masse and empties the table, and the table is instantly equipped for the next group. At each table opening, there are 2 kilos of rice in the large rice pot in the middle. Each philosopher eats 100 grams of rice in each cycle of eating and thinking. When the rice in the pot is finished, the philosopher who can't even eat a bite remains in the group of 8 people, the group orders the waiter to freshen the pot (2 pounds) before getting up from the table, and the eating cycle starts again. This cycle continues if you still can not eat at all since the first session at the table when the rice runs out. When everyone at the table eats more or less something, the group pays the bill and gets up. Thread will be finished with the group that leaves the table. Program: Write a C program that solves the above problem so that there is a separate thread for each philosopher. When the program starts, let it take the number of philosopher groups as a parameter from the command line. For example, 100 groups. There is a slow eater, there is a good eater, there is little to think about, there is a lot to think about. So, the eating and thinking times also get a random value dec each step between 1 and 5 milliseconds. Bring me the check as an output.Those included in the account get: Table opening+ table refresher + rice cost. Opening a table from scratch costs 99.90 TL for each and refreshing the table costs 19.90 TL, solid brass weight is 20 TL. Your program should use the Pthreads library on a Unix-based basis. You can use the ready-made mutex, semaphore and monitor structures in the Pthreads library. At the end of your program, the table-based (detailed account breakdown, how much rice you beat, number of table refreshments, table opening price) and the total account should be subtracted on a table-based basis and printed on the screen.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!