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,...
-
A water pipe is connected to a double-U manometer as shown in Fig. P1-111E at a location where the local atmospheric pressure is 14.2 psia. Determine the absolute pressure at the center of the pipe....
-
Consider the gasoline mileage data in Table B.3. Split the data into estimation and prediction sets. a. Evaluate the statistical properties of these data sets. b. Fit a model involving \(x_{1}\) and...
-
Alfonso Sheen recently opened his own accounting firm, which he operates as a corporation. The name of the new entity is Alfonso Sheen, CPA. Sheen experienced the following events during the...
-
A search tool finds online information based on criteria you specify or selections you make. Search tools include search engines and search boxes on webpages. The more effectively you use search...
-
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)?
-
What is meant by an unsecured loan? Are these loans an important form of bank lending?
-
An analyst at a real estate investment management firm seeks to establish expectations for rate of return for properties in the industrial sector over the next year. She has obtained the following...
-
An analyst is reviewing various asset alternatives and is presented with the following information relating to the broad equity market of Switzerland and various industries within the Swiss market...
-
Time value of money calculations may not be required in an economic evaluation for all of the following reasons except a. annual cash flows are proportional to the first year cash flow b. inflation...
-
A bottled mango juice drink must contain at least 17 percent mango juice for proper taste. The drink is created by blending unprocessed juice from two orchards. RightRipe Orchard sells unprocessed...
-
Reconsider the preceding problem assuming that the sequence can be rearranged such that the processing step with the 5 percent scrap rate occurs last rather than first. Using this redesigned...
-
British Petroleums income statement was prepared using IFRS is presented below (in $ millions). ExxonMobil Corporations income statement prepared using U.S. GAAP is presented below (in $ millions)....
-
You are thinking of investing in one of two companies. In one annual report, the auditors opinion states that the financial statements were prepared in accordance with generally accepted accounting...
-
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...
-
Why is depreciation called the tax shield? How does this impact how cash flows are calculated?
-
Acqusitions are divided into three types namely i) Merger or Consolidation, ii) Acquisition of Stocks and iii) Acquisition of Assets. Explain briefly the characteristics of Acquisition of Assets.
-
Explain why a) an increase in free cash flow may also increase the agency cost of equity; and b) an increase in dividends or debt may be effective in making sure free cash flow are used in the best...
Study smarter with the SolutionInn App