In the solution to the dining philosophers problem (Fig. 2-20), why is the state variable set to
Question:
In the solution to the dining philosophers problem (Fig. 2-20), why is the state variable set to HUNGRY in the procedure take_forks?
Transcribed Image Text:
#define N #define LEFT #define RIGHT #define THINKING void philosopher(int i) { } #define HUNGRY #define EATING typedef int semaphore; int state[N]; semaphore mutex = 1; semaphore s[N]; 5 } (i+N-1)%N (i+1)%N eat(); put_forks(i); 0 1 2 while (TRUE) { think(); take_forks(i); /* number of philosophers */ /* number of i's left neighbor */ /* number of i's right neighbor */ /* philosopher is thinking */ /* philosopher is trying to get forks */ /* philosopher is eating */ /* semaphores are a special kind of int */ /* array to keep track of everyone's state */ /* mutual exclusion for critical regions */ /* one semaphore per philosopher */ /* i: philosopher number, from 0 to N-1 */ /* repeat forever */ /* philosopher is thinking */ /* acquire two forks or block */ /* yum-yum, spaghetti */ /* put both forks back on table */
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 57% (7 reviews)
The state variable is set to HUNGRY in the takeforks procedure of the solution to the dining philosophers problem to indicate that a philosopher is cu...View the full answer
Answered By
Fahmin Arakkal
Tutoring and Contributing expert question and answers to teachers and students.
Primarily oversees the Heat and Mass Transfer contents presented on websites and blogs.
Responsible for Creating, Editing, Updating all contents related Chemical Engineering in
latex language
4.40+
8+ Reviews
22+ Question Solved
Related Book For
Operating Systems Design And Implementation
ISBN: 9780131429383
3rd Edition
Authors: Andrew Tanenbaum, Albert Woodhull
Question Posted:
Students also viewed these Computer science questions
-
We now turn to the dining philosophers problem, introduced. Five philosophers live in a house, where a table is laid for them. The life of each philosopher consists principally of thinking and...
-
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...
-
The dining philosophers problem is a classic exercise in synchronization (Figure 13.20). Five philosophers sit around a circular table. In the center is a large communal plate of spaghetti. Each...
-
A total weighted score of in an External Factor Evaluation (EFE) Matrix indicates that an organization is responding in an outstanding way to existing opportunities and threats in its industry. Oa....
-
Foot Locker, Inc.s consolidated financial statements in Appendix B at the end of this book report a number of liabilities. Show amounts in thousands. 1. The current liability section of Foot Locker,...
-
What role do short-term investments in securities play in managing the cash balance?
-
Which of the following describes an IASB requirement that the FASB has adopted as part of the short-term convergence project? LO4 a. Following the IASB format for presentation of a statement of...
-
A ticket from Indianapolis to Orlando on Deleast Airlines sells for $150. The plane can hold 100 people. It costs Deleast $8000 to fly an empty plane. Each person on the plane incurs variable costs...
-
Josephs, a popular pizza hang-out, has a thriving delivery business. Josephs has a fleet of three delivery automobiles. The company uses the units-of-activity method of depreciation. Prior to making...
-
A fast food restaurant has four kinds of employees: (1) order takers, who take customers orders; (2) cooks, who prepare the food; (3) packaging specialists, who stuff the food into bags; and (4)...
-
Is a statement like ln file file.lock an effective locking mechanism for a user program like the scripts used in the previous problem? Why (or why not)?
-
Suppose that two fair dice (one red and one green) are rolled. Define the events A: a 1 or a 2 shows on the red die B: a 3, 4, or 5 shows on the green die C: the dice total is 4, 11, or 12 Show that...
-
Q1. (a) Name the types of reactions that organic compounds undergo (b) Differentiate between (i) electrophile and nucleophile
-
CH4 Br, Ligtht Q2. (a) CH3Br + HBr Propose a mechanism for the reaction; indicating initiation, propagation and termination.
-
Q4. Complete the following reactions by drawing the structure(s) of the product(s) formed.
-
1. Why did the Iconoclast emperors believe that using images in worship was wrong? 2. How are recent examples of iconoclasm similar to those of the early medieval period? 3. Why is iconoclasm a...
-
1. Difference Between Essential and Non-Essential Nutrients 2. what is Conditionally Essential Nutrients? explain with examples
-
United Fabrics International, Inc., bought a fabric design from an Italian designer and registered a copyright to it with the U.S. Copyright Office. When Macy's, Inc., began selling garments with a...
-
Fred Farmer needs to prepare a balance sheet for his bank. He spent the day getting the following information. Fred needs your help to build a balance sheet and evaluate it. The information was...
-
The java.util.Collection interface includes a method, contains(o), that returns true if the collection contains any object that equals Object o. Implement such a method in the ArrayList class of...
-
Describe a fast recursive algorithm for reversing a singly linked list L, so that the ordering of the nodes becomes opposite of what it was before.
-
Communication security is extremely important in computer networks, and one way many network protocols achieve security is to encrypt messages. Typical cryptographic schemes for the secure...
-
Suppose First Fidelity Bank engaged in the following transactions: (Click the icon to view the transactions.) Journalize the 2018 and 2019 transactions on First Fidelity's books. Explanations are not...
-
Financial data for Joel de Paris, Inc., for last year follow: Joel de Paris, Inc. Balance Sheet Beginning Balance Ending Balance Assets Cash Accounts receivable Inventory Plant and equipment, net...
-
Supply costs at Coulthard Corporation's chain of gyms are listed below: March April May June July August September October November Client-Visits 11,666 11,462 11,994 13,900 11,726 11, 212 12,006...
Study smarter with the SolutionInn App