The Dining Philosophers Problem: N philosophers are sitting at a round table. In the center of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The Dining Philosophers Problem: N philosophers are sitting at a round table. In the center of the table, there is a bowl of rice. Between each pair of philosopher is a single chopstick. A philosopher is in one of three states: thinking, hungry and eating. At various times a thinking philosopher gets hungry. A hungry philosopher attempts to pick up one of the adjacent chopsticks, then the other one (not both at the same time). If the philosopher is able to obtain the pair of chopsticks, then the philosopher eats for a period of time. After eating, the philosopher puts the chopsticks down and returns thinking. In this project, you are supposed to write a C program for the dining philosopher problem, which will implement a deadlock-free solution with maximum concurrency. The program should work for any number of philosophers (odd numbers, maximum 27). In the program, a thread will express a philosopher. These threads will be spawned by the main thread, which is not a philosopher. You need to use Pthreads, mutex and condition variables to synchronize. You can use monitor based solutions or semaphores that are deadlock free. The program will be named phsp and will take the following arguments: php For the arguments; is the minimum thinking time for a philosopher, is the maximum thinking time; is the minimum dining time, is the maximum dining time. Use miliseconds as unit. The highest value that these parameters can take is 60seconds and lowest value that these parameters can take is 1ms. is the distribution and it can be either "uniform" or "exponential". The mean parameters for exponential distributions are (min think+max think)/2 or (min dine+max.dine)/2. The thinking time and dining time for a philosopher will be selected randomly according to the specified dst, and the mean value. For exponential distribution; simply generate a random value with exponential distribution, and if the value is not in range, repeat it. Each philosopher will dine times. The program should terminate after all of the philosophers complete dining (num times). A sample initiation could be: phsp 5 500 1000 50 100 exponential 100 The Dining Philosophers Problem: N philosophers are sitting at a round table. In the center of the table, there is a bowl of rice. Between each pair of philosopher is a single chopstick. A philosopher is in one of three states: thinking, hungry and eating. At various times a thinking philosopher gets hungry. A hungry philosopher attempts to pick up one of the adjacent chopsticks, then the other one (not both at the same time). If the philosopher is able to obtain the pair of chopsticks, then the philosopher eats for a period of time. After eating, the philosopher puts the chopsticks down and returns thinking. In this project, you are supposed to write a C program for the dining philosopher problem, which will implement a deadlock-free solution with maximum concurrency. The program should work for any number of philosophers (odd numbers, maximum 27). In the program, a thread will express a philosopher. These threads will be spawned by the main thread, which is not a philosopher. You need to use Pthreads, mutex and condition variables to synchronize. You can use monitor based solutions or semaphores that are deadlock free. The program will be named phsp and will take the following arguments: php For the arguments; is the minimum thinking time for a philosopher, is the maximum thinking time; is the minimum dining time, is the maximum dining time. Use miliseconds as unit. The highest value that these parameters can take is 60seconds and lowest value that these parameters can take is 1ms. is the distribution and it can be either "uniform" or "exponential". The mean parameters for exponential distributions are (min think+max think)/2 or (min dine+max.dine)/2. The thinking time and dining time for a philosopher will be selected randomly according to the specified dst, and the mean value. For exponential distribution; simply generate a random value with exponential distribution, and if the value is not in range, repeat it. Each philosopher will dine times. The program should terminate after all of the philosophers complete dining (num times). A sample initiation could be: phsp 5 500 1000 50 100 exponential 100
Expert Answer:
Answer rating: 100% (QA)
The image you provided contains the description of the Dining Philosophers problem which is a classic synchronization problem to illustrate the challe... View the full answer
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
The dining philosophers problem is a classic problem of synchronization and concurrency. The general problem is stated as philosophers sitting at a round table doing one of two things: eating or...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
When Ralph Lauren makes shirts to a customers exact preferences, what utility is provided?
-
Why are sole proprietorships the most popular form of ownership?
-
In response to the Sarbanes-Oxley Act, many small firms in the United States have opted to go dark delist their stock. Why might a company choose this route? What are the costs of going dark?
-
Prepare a statement of cash flows for the New Zealand Dairy Company for the year ended January 31, 2018. Interpret your results. New Zealand Dairy Company Balance Sheet for 01/31/2017 and 01/31/2018...
-
Sherwills statement of consolidated income is as follows: Net sales ..................... $658 Other income .................... 8 666 Costs and expenses: Cost of products sold ................. 418...
-
a) Investment in real estate is one of the booming business in Kenya today and most of companies and wealthy individuals have been venturing into the business. Understanding on the rights of real...
-
A production order quantity problem has a daily demand rate = 60 and a daily production rate = 150. The production order quantity for this problem is approximately 600 units and the set-up cost is...
-
David E. Ross, his two brothers, and their families operated and owned the entire stock of five businesses. Ross had three children: Rod, David II, and Betsy. David II and Betsy were not involved in...
-
Some species of jellyfish use jet propulsion to get around, a much gentler form of jet propulsion than squid use. A small jellyfish takes water into its bell; the total mass of jellyfish and water is...
-
Squid rely on jet propulsion when a rapid escape is necessary. A 1.5 kg squid at rest pulls 0.10 kg of water into its mantle, then ejects this water at a remarkable 45 m/s. Right after this ejection,...
-
In 1973, a deed for land in Pitt County, North Carolina, was executed and delivered by Joel and Louisa Tyson unto M. H. Jackson and wife Maggie Jackson, for and during the term of their natural lives...
-
In May 2006, Fred Parramore executed four deeds, each conveying a life estate in his land to him and his wife and a remainder interest in one-fourth of his land to each of his four children: Alney,...
-
3. Blocks A and B are the particles that are connected with a cable as shown in the figure. The mass of Block A is 4- Kg. The mass of Block B is 10-Kg and stays at rest position at point A. Block B...
-
Independent random samples of sizes n1 = 30 and n2 = 50 are taken from two normal populations having the means 1 = 78 and 2 = 75 and the variances 21 = 150 and 22 = 200. Use the results of Exercise...
-
Quite often, you would expect that given a timing diagram containing a description of changes that take place on a data input D and a clock input C (as in Figures B.8.3 and B.8.6 on pages B-52 and...
-
Calculate the sum of 2.6125 10 1 and 4.150390625 10 -1 by hand, assuming A and B are stored in the 16-bit half precision described in Exercise 3.27. Assume 1 guard, 1 round bit, and 1 sticky bit,...
-
Translate the following loop into C. Assume that the C-level integer i is held in register $t1, $s2 holds the C-level integer called result, and $s0 holds the base address of the integer MemArray....
-
The market value of equity for a company can be calculated as enterprise value: A. Minus market value of debt, preferred stock, and short-term investments. B. Plus market value of debt and preferred...
-
Asset-based valuation models are best suited to companies where the capital structure does not have a high proportion of: A. Debt. B. Intangible assets. C. Current assets and liabilities.
-
Which of the following is most likely a reason for using asset-based valuation? A. The analyst is valuing a privately held company. B. The company has a relatively high level of intangible assets. C....
Study smarter with the SolutionInn App