Write program to simulate ipc problem


Problem:

The Cigarette-Smokers Problem:

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.

Question- Write program to simulate one of the following IPC problems. This is individual project. Display messages to the screen to show the state of the system. Make sure to use semaphores to synchronize the processes/threads.

Any help would be greatly appreciated!

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write program to simulate ipc problem
Reference No:- TGS0893788

Expected delivery within 24 Hours