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,...
-
Before adjustments and closing on December 31, 2011, the current accounts of Seymour and Associates indicated the following balances. The terms of an outstanding long-term note payable stale that...
-
Many people have difficulty saving money for a variety of reasons. Research some typical roadblocks to saving money. Write About It Write a paragraph explaining at least three reasons and how you...
-
Sticky Polymers Inc. processes a base chemical into plastic. Standard costs and actual costs for direct materials, direct labor, and factory overhead incurred for the manufacture of 10,750 units of...
-
At? year-end, Slippery Company has cash of $ 19000, current accounts receivable of $ 120000?, merchandise inventory of $26000, and prepaid expenses totaling $ 4300. Liabilities of $ 40000 must be ...
-
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 you want to conduct a left-tailed hypothesis test at the 5% significance level. How must the critical value be chosen? In problem pertain to the critical-value approach to hypothesis...
-
Fast Cars Inc. was authorized to issue 50,000 $1.50 preferred shares and 300,000 common shares. During 2023, its first year of operations, the following selected transactions occurred: Jan. 1 4,900...
-
Fundamental rights" are few and far between. Because these are judicially created rights, courts should be cautious in granting new rights. Judges should begin their assessment of whether a right is...
-
Brazil is booming, but for most of the 20th century, it was an economic mess. For a while, inflation was so high that grocery stores were raising their prices every day. Shoppers would run ahead of...
-
Neglecting air resistance, horizontal and vertical displacements of a projectile launched at an angle of from the horizontal with an initial velocity, vo, are given by x(t) = vo cos(0) t y(t) =vo...
-
Why do drug firms give discounts voluntarily? Do other healthcare providers routinely give discounts to some customers? Why do the uninsured typically pay the highest prices? Why would a hospital...
-
On August 4, 2014, Cappio Corporation purchased 1,000 shares of Maxwell Company for $ 45,000. The following information applies to the fair value of Maxwell Company: Per Share 12/ 31/ 2014.. $ 52 12/...
-
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...
-
Payments to principal on a mortgage a . represent the cost to the individual for taking out the loan. b . increase the market value of the home. c . decrease the market value of the home. d ....
-
Since its incorporation, Lookout Ltd. has been a CCPC. Lookout's taxable income was $755,700 for its taxation year ending December 31, 2021, and $811,900 for its taxation year ending December 31,...
-
If demand for X goes up due an increase in the price of Y , X and Y are - - - - - - - - - - - . Question 1 4 options: Complements Substitutes Dependent Nonexistent Inconsistent
Study smarter with the SolutionInn App