Task 6: Cigarette Smokers Problem

$30.00 $24.00

Problem Description Consider a system with 3 smoker processes and 1 agent process. Each smoker continuously rolls a cigarette and then smokes it. The smoker needs three ingredients: tobacco, paper, and matches. One of the smokers has paper, another has tobacco, and the third has matches. The agent has an infinite supply of all three…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Problem Description

Consider a system with 3 smoker processes and 1 agent process. Each smoker continuously rolls a cigarette and then smokes it. The smoker needs three ingredients: tobacco, paper, and matches. One of the smokers has paper, another has tobacco, and the third has matches. The agent has an infinite supply of all three materials and (randomly) places two of the ingredients on the table each time. The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredients, and the cycle repeats.

TO DO: Write two programs to synchronize the agent and smoker processes: one using semaphores and another using pthread libraries

Instructions

  • Though the description says the agent process can infinitely supply two of the three ingredients, you can assume that the agent places ingredients only a finite number of times, say for example 10.

  • You need to use the sem.h header file in your semaphore-based solution.

Submission Instructions

Submit your solution to the cigarette smokers problem along with a brief report (atmost 1 page) on how your solution synchronizes the four processes. Draw comparison between semaphore and pthread library based solutions highlighting the merits and demerits of both approaches. The C solution files must be internally documented.

Zip your source & explanation text files into a single folder as: task6_lastname.zip. Email your zip file with the subject line, “Task 6 – CSc 332(L) – lastname“.

******

1

Task 6: Cigarette Smokers Problem
$30.00 $24.00