Question

For this task, consider the producer/consumer problem. You have a buffer of 4096KB there are 4...

For this task, consider the producer/consumer problem. You have a buffer of 4096KB there are 4 consumer threads and 2 producer threads.

2.1 What problem may arise when simultaneously performing 4 consume from buffer and 1 produce to buffer operations? Assume that there are currently 3 elements of 1MB each in the buffer.

2.2 What problem may arise when performing 4 consume from buffer operations simultaneously if there are 4 elements of 1MB each in the buffer?

2.3 Given that a consumer cannot consume from the buffer when the producer is writing to the buffer, how would you implement this producer/consumer problem such that the maximum parallelism can be achieved?

Homework Answers

Answer #1

a. As the producer and consumer will run the operations simultaneously, thus if the first operation would be done for the producer then it would be fine, and if the first operation is for the consumer. Then it can cause the problem as there are not enough buffer. Thus this can lead the producer to starve and will have to wait until the producer is done producing 1MB buffer.

b. This can go on seamless as there is the need of 4 and which is present in the buffer. Thus the consumer will not starve and will not have to wait for the buffer.

c. So for this problem, we can go for the mutex locks in which we will check for the lock before entering the producer or consumer operation. and if it is not locked means no operation is going on thus we can enter in and make the mutex lock enabled after entering. Thus no one can enter the loop while other is working.

Thanks

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the producer/consumer problem where the producer and consumer execute in separate processes synchronized by sempahores....
Consider the producer/consumer problem where the producer and consumer execute in separate processes synchronized by sempahores. Now, assume the producer can generate (data) items quickly and it is decided to update the consumer to a multi-threaded consumer. Also, assume the consumer has been changed to form three new consumer threads in addition to the thread running main(). You DO NOT have to write code for forming three new threads in the consumer. Now it is a requirement that all consumer...
Consider the producer/consumer problem where the producer and consumer execute in separate processes synchronized by sempahores....
Consider the producer/consumer problem where the producer and consumer execute in separate processes synchronized by sempahores. Now, assume the producer can generate (data) items quickly and it is decided to update the consumer to a multi-threaded consumer. Also, assume the consumer has been changed to form three new consumer threads in addition to the thread running main(). You DO NOT have to write code for forming three new threads in the consumer. Now it is a requirement that all consumer...
Have you ever wondered what it means to click the “offset carbon emissions” button when you...
Have you ever wondered what it means to click the “offset carbon emissions” button when you book a flight or train trip? It adds a small cost to your ticket, but how does this reduce emissions? The money is typically used to fund projects that reduce carbon emissions. One such project type is the introduction of more efficient cooking stoves into communities. Much of the world uses inefficient charcoal or wood stoves that result in excessive indoor air pollution, deforestation,...
Explain the complete HAZOP procedure as followed in the industry. See summary below. Explain all the...
Explain the complete HAZOP procedure as followed in the industry. See summary below. Explain all the main parts of HAZOP study in details given in the Pdf file including: 1. Overview (including definitions and usage) 2. Hazop methodology (including phases like definition, preparation, examination, documentation and follow-up). Give examples also 3. Risk review 4. Risk communication Guidance: Study the procedure carefully and then write the answers in your own words. Hazard & Operability Analysis (HAZOP) 1   Overview: Hazard and Operability...
1-How important do you believe it is to be task-oriented and relationship-orientated? How would you describe...
1-How important do you believe it is to be task-oriented and relationship-orientated? How would you describe Musk? 2-Why do you think Musk is successful in overcoming obstacles and handling conflict? How do you overcome obstacles in influencing individuals in your life? 3-Besides the personality traits given in chapter 2, what other traits attribute to a great leader? Recognizing Your Traits The definition of intelligence is the ability to acquire and apply knowledge and skills. Elon Musk knew little about rockets...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic...
provide 3-4 paragraphs post (team 2) 1-What are 4 key things you learned about the topic from reading their paper? 2-How does the topic relate to you and your current or past job? 3-Critique the paper in terms of the organization and quality.1- Employee Stress and how it has an Adverse Effect on a Company This paper explores employee stress and how it has an adverse effect on a company, its employees and the organization. Job stress can have a...
Pick 4 questions to answer that you feel confident that you picked the correct answer Regarding...
Pick 4 questions to answer that you feel confident that you picked the correct answer Regarding setting the budget for integrated marketing communications options: - all-you-can-afford approaches involve setting objectives and then specifying tasks needed to achieve them. - incremental technique tries to set budgets based on other firms’ decisions. - competitive budgeting establishes the same budget year after year. - percentage-of-sales methods tend to ignore the promotion-causes-sales relationship. Many advertisements work primarily through recognition which means - that the...
The project has been performing as planned, and the team members have been exhibiting increasing levels...
The project has been performing as planned, and the team members have been exhibiting increasing levels of trust between each other. The sponsor and the buyer have been satisfied with the delivery of business value, and user acceptance testing results are positive. A technical expert consulting with the team has expressed concerns that the team is not in agreement on the best way to deliver to the next review. If the project manager wants to support the team in reaching...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
Como Tool and Die was a second-tier component supplier to the auto industry. Its largest customer...
Como Tool and Die was a second-tier component supplier to the auto industry. Its largest customer was Ford Motor Company. Como had a reputation for delivering a quality product. During the 1980s and the early 1990s, Como’s business grew because of its commitment to quality. Emphasis was on manufacturing operations, and few attempts were made to use project management. All work was controlled by line managers who, more often than not, were overburdened with work. The culture at Como underwent...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT