1. (6%) The following pseudo-code is a solution to the infinite-buffer producer-consumer problem using semaphores discussed...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. (6%) The following pseudo-code is a solution to the infinite-buffer producer-consumer problem using semaphores discussed in class, where semaphore S is used to ensure mutual exclusion and the value of semaphore N is equal to the number of items in the shared buffer. Answer the questions following the code. void producer(){ while (true){ produce(); semWait(S); append(); Semaphore N = 0, S = 1; void consumer() { while (true){ semWait(N); semWait(S); take(); semSignal(S); semSignal(N); semSignal(S); consume(); A) Why does the consumer code require the semWait(N) operation? → Answer: B) If the operations semSignal(S) and semSignal(N) in the producer code are accidentally reversed, can the consumer program still function properly? Justify your answer. → Answer: C) If the operations semWait(N) and semWait(S) in the consumer code are accidentally reversed, will this accident produce a serious fatal flaw? Justify your answer. → Answer: 1. (6%) The following pseudo-code is a solution to the infinite-buffer producer-consumer problem using semaphores discussed in class, where semaphore S is used to ensure mutual exclusion and the value of semaphore N is equal to the number of items in the shared buffer. Answer the questions following the code. void producer(){ while (true){ produce(); semWait(S); append(); Semaphore N = 0, S = 1; void consumer() { while (true){ semWait(N); semWait(S); take(); semSignal(S); semSignal(N); semSignal(S); consume(); A) Why does the consumer code require the semWait(N) operation? → Answer: B) If the operations semSignal(S) and semSignal(N) in the producer code are accidentally reversed, can the consumer program still function properly? Justify your answer. → Answer: C) If the operations semWait(N) and semWait(S) in the consumer code are accidentally reversed, will this accident produce a serious fatal flaw? Justify your answer. → Answer:
Expert Answer:
Answer rating: 100% (QA)
Lets break down the given pseudocode for the infinitebuffer producerconsumer problem using semaphores and address each part A B C step by step Produce... View the full answer
Related Book For
Operating Systems Internals and Design Principles
ISBN: 978-0133805918
8th edition
Authors: William Stallings
Posted Date:
Students also viewed these programming questions
-
Portray in words what transforms you would have to make to your execution to some degree (a) to accomplish this and remark on the benefits and detriments of this thought.You are approached to compose...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Arrange the following events in the correct temporal sequence during eukaryotic cell division, starting with the earliest: (a) condensation of the chromosomes, (b) Movement of chromosomes to the...
-
As of 2008, per capita spending on health care in the United States was about $8,000. If this amount increased by 5 percent a year, what would be the amount of per capital spending for health care in...
-
Cool Spring Company produces premium bottled water. In the second department, the Bottling Department, conversion costs are incurred evenly throughout the bottling process, but packaging materials...
-
The data in Exercise 2.174. Use technology to find the correlation for the data indicated. Data From Exercise 2.174: Make a scatterplot of the data. Put the $X$ variable on the horizontal axis and...
-
Liedtke's advisors suggest that Texaco has more options in the face of Pennzoil's $5 billion counteroffer than simply to refuse or accept. In particular, they might counteroffer, probably with an...
-
Explain the difference between traditional and enterprise risk management. Explain why enterprise risk management is a more effective approach for today's organizations. Explain key drivers of...
-
The Golden Oranges Nursery, which provides facilities for pre-school children on a commercial basis, is preparing its cash budget for next year. A profile of the estimated revenues and expenses for...
-
Determine the simplest forms of a. Sij Sjk Ski b. Elsta2Tts
-
Consider two countries Pakistan and USA trading with each other, with Pakistan exporting garments to USA and USA exporting aircrafts to Pakistan. Use the Standard Trade Model to illustrate the gains...
-
Week 2: Homework 3 6 points Direct labor-hours Direct materials Direct labor cost Machine-hours Check my work mode: This shows what is correct or incorrect for the work you have completed so far. It...
-
You are a junior analyst at New Guy Financial Management. The Head Analyst is doing an analysis for a potential client and explaining the value of diversificat and has asked you to look at the...
-
Identify and research a US public company in your pathway. It should be on the Fortune 500 list. Don't use a company that someone has already used. Access their most recent (less than 12 months)...
-
The Change Corporation has two different bonds currently outstanding. Bond M has a face value of $30,000 and matures in 20 years. The bond makes no payments for the first six years, then pays $3,100...
-
Substances those are partially dissolved in water are commonly known as a. hydrophilic / hydrophobic b. false statement c. hydrophilic d. hydrophobic e. all given choices are incorrect
-
A red card is illuminated by red light. What color will the card appear? What if its illuminated by blue light?
-
Assume that at time 5 no system resources are being used except for the processor and memory. Now consider the following events: At time 5: P1 executes a command to read from disk unit 3. At time 15:...
-
Show that message passing and semaphores have equivalent functionality by a. Implementing message passing using semaphores. b. Implementing a semaphore using message passing.
-
Consider the disk system described in Problem 11.7, and assume that the disk rotates at 360 rpm. A processor reads one sector from the disk using interrupt-driven I/O, with one interrupt per byte. If...
-
Example In January 2004, a Mars Exploration Rover touched down on the surface of Mars and rolled out for exploration ( Figure
-
Does the snowflake have rotational symmetry in Figure 1.6? If yes, describe the ways in which the flake can be rotated without changing its appearance. Does it have reflection symmetry? If yes,...
-
A battery-operated wall clock no longer keeps timeneither hand moves. Develop a hypothesis explaining why it fails to work, and then make a prediction that permits you to test your hypothesis....
Healthcare Asset Management A Complete Guide 2020 Edition 1st Edition - ISBN: 0655921133 - Free Book
Study smarter with the SolutionInn App