Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a system with three smoker threads/processes and one agent thread/proce

ID: 3565599 • Letter: C

Question

Consider a system with three smoker threads/processes and one agent thread/process. Each smoker continuously rolls a cigarette and then smokes it. But to roll and smoke a cigarette, the smoker needs three ingredients: tobacco, paper, and matches. One of the smoker threads/processes has paper, another has tobacco, and the third has matches. The agent has an infinite supply of all three materials. The agent places two of the ingredients on the table. The smoker who has the remaining ingredient then makes and smokes a cigarette. When the appropriate smoker is done, he or she wakes up the agent. The agent then puts out another two of the three ingredients at random, and cycle repeats. Write a program to synchronize the agent and the smokers.Write program to simulate it.

Explanation / Answer

// the program is implemented using three files, smoker.cpp and smoker-main.cpp and smoker.h

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote