The solution to the first readers-writers problem in Figure 12.26 gives priority to readers, but this priority
Question:
The solution to the first readers-writers problem in Figure 12.26 gives priority to readers, but this priority is weak in the sense that a writer leaving its critical section might restart a waiting writer instead of a waiting reader. Describe a scenario where this weak priority would allow a collection of writers to starve a reader.
Figure 12.26
Transcribed Image Text:
/* Global variables */ int readcnt; /* Initially 0 */ sem_t mutex, w; /* Both initially = 1 */ void reader (void) { while (1) { } } P(&mutex); readcnt++; if (readcnt P (&W); V (&mutex); } P (&mutex); readcnt--; } void writer (void) { if (readcnt V (&W); V (&mutex); /* Critical section */ /* Reading happens */ while (1) { P (&w); == V(&W); = == 1) /* First in */ 0) /* Last out */ /* Critical section */ /*Writing happens */
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (2 reviews)
Suppose that a particular semaphore implementation uses a LIFO stack of t...View the full answer
Answered By
Hemstone Ouma
"Hi there! My name is Hemstone Ouma and I am a computer scientist with a strong background in hands-on experience skills such as programming, sofware development and testing to name just a few. I have a degree in computer science from Dedan Kimathi University of Technology and a Masters degree from the University of Nairobi in Business Education. I have spent the past 6 years working in the field, gaining a wide range of skills and knowledge. In my current role as a programmer, I have had the opportunity to work on a variety of projects and have developed a strong understanding of several programming languages such as python, java, C++, C# and Javascript.
In addition to my professional experience, I also have a passion for teaching and helping others to learn. I have experience as a tutor, both in a formal setting and on a one-on-one basis, and have a proven track record of helping students to succeed. I believe that with the right guidance and support, anyone can learn and excel in computer science.
I am excited to bring my skills and experience to a new opportunity and am always looking for ways to make an impact and grow as a professional. I am confident that my hands-on experience as a computer scientist and tutor make me a strong candidate for any role and I am excited to see where my career will take me next.
5.00+
8+ Reviews
22+ Question Solved
Related Book For
Computer Systems A Programmers Perspective
ISBN: 9781292101767
3rd Global Edition
Authors: Randal E. Bryant, David R. O'Hallaron
Question Posted:
Students also viewed these Computer science questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Find r(t) and v(t) given a(t) and the initial velocity and position. a(t) = (t, 4), v(0) = (3,-2), r(0) = (0,0)
-
Economists have forecast the following yearly inflation rates over the next 10 years: Year .........Inflation Rate 1 .............3.0 2 .............2.5 36 .............4.0 710 ............3.0...
-
How are the various lineations defined and how do they develop?
-
Redesign the fractionator of Example 6.8 using a random packing. The column is to be packed with 50-mm metal Pall rings. Determine the diameter of the tower, the height of packing in the stripping...
-
Colter Company prepares monthly cash budgets. Relevant data from operating budgets for 2014 are: All sales are on account. Collections are expected to be 50% in the month of sale, 30% in the first...
-
-. Use the Average Annual Costs of Owning and Operating a Car table below. If you drive 40,000 miles per year, what is the total annual expense for an electric car? (2 points) Average Annual Costs of...
-
Let p denote the number of producers, c the number of consumers, and n the buffer size in units of items. For each of the following scenarios, indicate whether the mutex semaphore in sbuf_insert and...
-
Fill in the blanks for the parallel program in the following table. Assume strong scaling. Threads (t) Cores (p) Running time (Tp) Speedup (S) Efficiency (E) 1 1 16 1 100% 44 8 00 00 8 8 4
-
Suppose that for a renewal process N t , the interarrival times have the Poisson distribution with a mean of . Find the distribution of T n and write a formula for P(N 1 n). For which t an s is it...
-
1. Read the following list of things people value. Think about each value in terms of its importance as a guiding principle in your life. 2. Circle six of these 18 values to indicate that they are...
-
In what ways does the ACA help underserved populations? In what ways might it hurt underserved populations?
-
How might medical education address some of the health communication challenges presented in this chapter?
-
What do you see as the greatest specific cost and benefit of globalization?
-
The giant Asian pond turtle is endangered. It is also highly sought after for medicinal and food purposes. Would you hunt and kill one of these turtles for $20? For $10,000? At what price would you...
-
Do CPA firms have a responsibility to perform audits of charitable organizations for reduced or lower-than-normal audit fees? Defend your answer. Other than audit fees, what other benefits do...
-
Question 2 For an n x n matrix A = form) via (aij)
-
Assume a 15 cm diameter wafer has a cost of 12, contains 84 dies, and has 0.020 defects/cm 2 . Assume a 20 cm diameter wafer has a cost of 15, contains 100 dies, and has 0.031 defects/cm 2 . 1. Find...
-
Assume for arithmetic, load/store, and branch instructions, a processor has CP Is of 1, 12, and 5, respectively. Also assume that on a single processor a program requires the execution of 2.56E9...
-
Th e Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average, it consumed 10 W of static power and 90 W of dynamic power. The Core...
-
Cit129 hw6 ch6 assignment prelude to programming?
-
Critically evaluate the best practices implemented by Microsoft to compensate and motivate their employees and discuss discretionary benefits that you would recommend the organization to implement...
-
Test 2 1.Explain the reasons why the padding field is included in an ESP? [6 Marks] 2. List THREE (3) parameters that identified the SA. [3 Marks] 3. List any FOUR (4) services provided by IPSec....
Study smarter with the SolutionInn App