Now consider another correct solution to the preceding problem: a. Explain how this program works and why
Question:
Now consider another correct solution to the preceding problem:
a. Explain how this program works and why it is correct.
b. Does this solution differ from the preceding one in terms of the number of processes that can be unblocked at a time? Explain.
c. This program is an example of a general design pattern that is a uniform way to implement solutions to many concurrency problems using semaphores. It has been referred to as the Pass The Baton pattern. Describe the pattern.
Transcribed Image Text:
1 semaphore mutex 1, block 0; 2 int active 0, waiting - 0; boolean must_wait false; 3 4 5 6 semWait (mutex); if (must wait) { ++waiting; semSignal (mutex); semwait (block); --waiting; 7 8 9 10 11 }) 12 ++active; 13 must wait - active -- 3; 14 if (waiting > 0 && !must_wait) semSignal (block) ;; 15 16 17 else semSignal (mutex); 18 19 /* critical section */ 20 21 semWait (mutex); 22-active; if (active - 0) 23 24 must wait false; 25 if (waiting - 0 && !must_wait) 26 semSignal (block) ;; 27 28 else semSignal (mutex); /* share variables: semaphores, */ /* counters, and / /* state information */ /* Enter the mutual exclusion */ /* If there are (or were) 3, then */ /* Wait for all current users to depart */ /* We've got the mutual exclusion; update count */ /* we must wait, but we must leave */ /* the mutual exclusion first */ /* Update active count, and remember */ /* if the count reached 3 */ /* If there are others waiting */ /* and we don't yet have 3 active, */ /* unblock a waiting process */ open the mutual exclusion */ /* otherwise /* Enter mutual exclusion */ /* and update the active count */ /* If last one to leave? */ /* set up to let new processes enter */ /* If there are others waiting / /* and we don't have 3 active, */ /* unblock a waiting process */ open the mutual exclusion */ /* otherwise
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (4 reviews)
ANSWER a This program works by first acquiring the mutex semaphore If the mustwait flag is set then ...View the full answer
Answered By
Aketch Cindy Sunday
I am a certified tutor with over two years of experience tutoring . I have a passion for helping students learn and grow, and I firmly believe that every student has the potential to be successful. I have a wide range of experience working with students of all ages and abilities, and I am confident that I can help students succeed in school.
I have experience working with students who have a wide range of abilities. I have also worked with gifted and talented students, and I am familiar with a variety of enrichment and acceleration strategies.
I am a patient and supportive tutor who is dedicated to helping my students reach their full potential. Thank you for your time and consideration.
0.00
0 Reviews
10+ Question Solved
Related Book For
Operating Systems Internals And Design Principles
ISBN: 9781292214290
9th Global Edition
Authors: Stallings William
Question Posted:
Students also viewed these Computer science questions
-
Explain why percentage depletion has been referred to as a government subsidy.
-
How will your answer to the preceding problem differ if the tuition charged by outside universities is $12,000/yr? What is the economic interpretation of a value of k greater than 1?
-
The equity method has been referred to as a one-line consolidation. What might prompt this description?
-
Water is an essential resource. For that reason moral considerations exert considerable pressure to assure that everyone has access to at least enough water to survive. Yet it appears that equity and...
-
Is there a significant interaction between supplier and shift in Table 15.5.4? Justify and interpret your answer. TABLE 15.5.4 Average Quality Scores and ANOVA Table Supplier A Supplier B Supplier C...
-
Find the slope of the tangent to the parametric curve at the indicated point. x = t 2 + 2t, y = 2 t 2t 0 (15,2) X
-
What does argv provide to our program?
-
Magic Enterprises borrowed $18,000 from the local bank on July 1, 2010, when the company was started. The note had an 8 percent annual interest rate and a one-year term to maturity. Magic Enterprises...
-
An aluminum flagpole is 34 m high. By how much does its length increase as the temperature increases by 23 C? (The linear expansion coefficient of aluminum is 23 x 10-6 /C)
-
You, CPA, work as a consultant on various engagements. Your client, Over The Edge Ltd. (OTE), has grown from a small custom snowboard manufacturer servicing the local market to a multinational...
-
Why cant you disallow mutual exclusion in order to prevent deadlocks?
-
List some of the methods that may be adopted to recover from deadlocks.
-
Find the dynamic and kinematic viscosities of kerosene, SAE 10W-30 motor oil, and water at a temperature of 50C.
-
Reread the Opening Profile. After doing this, make a list of all the things that you think that Jessica Truesdale has done right in building True You Cosmetics marketing program.
-
You work in the human resource department at the headquarters of a multinational corporation. Your company is about to send a number of managers overseas as expatriates to France and New Zealand. You...
-
Think of the current point that youre at in your career or educational process. Do you think youd be capable of owning and operating a franchise today or shortly after you graduate? If so, what type...
-
The Bureau of Economic Analysis is an agency of the U.S. Department of Commerce. It lists data about the U.S. economic accounts, including current investment positions and the amount of direct...
-
The top management team of your not-for-profit organization would like to find out more about investing in environmentally responsible companies in Europe. FTSE develops various indexes for the...
-
Why are committee reports useful to a tax researcher?
-
A liquid flows upward through a valve situated in a vertical pipe. Calculate the differential pressure (kPa) between points A and B. The mean velocity of the flow is 4.1 m/s. The specific gravity of...
-
Let buddyk(x) = address of the buddy of the block of size 2k whose address is x. Write a general expression for buddyk(x).
-
The Fibonacci sequence is defined as follows: a. Could this sequence be used to establish a buddy system? b. What would be the advantage of this system over the binary buddy system described in this...
-
During the course of execution of a program, the processor will increment the contents of the instruction register (program counter) by one word after each instruction fetch, but will alter the...
-
How to Manage 5 Generations in the Modern Workplace What is the biggest challenge you have experienced, or expect to experience, working in an office with someone from an older generation than you?...
-
Identify the specific purpose the writer shows in this topic sentence. When I was a child, I was always afraid of heights. A. to explain how to do something B. to convince readers of something C....
-
Look up the definition of going viral in your book about (political communication chapter) how has it changed political communication? You are free to use examples of viral political memes and/or...
Study smarter with the SolutionInn App