Google Answers Logo
View Question
 
Q: CS4560-Operating System_#2 ( No Answer,   0 Comments )
Question  
Subject: CS4560-Operating System_#2
Category: Computers > Operating Systems
Asked by: enm-ga
List Price: $10.00
Posted: 12 Jun 2003 03:42 PDT
Expires: 12 Jul 2003 03:42 PDT
Question ID: 216383
C S 4560
Write a C or C++ program using POSIX threads which implements a
solution to the Cigarette Smoker's Problem (Exercise 6.8 in the text,
also given below) that is free from deadlock. The agent and each
smoker should run as a separate thread. The state of the table must be
stored in a shared variable (e.g., a struct). The agent should choose
which pair of supplies to place out at random. Your program should
generate a line of output each time a smoker changes state: starts
smoking, stops smoking. Terminate the threads and exit the program
after the agent has enabled a total of 30 cigarettes to be smoked.
Hand in a commented, readable listing of your program and output from
two or more runs (each run should be different due to the random
selections by the agent (seed the random number generator differently
each run)).
The Cigarette-Smokers Problem
Consider a system with three smoker processes and one agent 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 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 smoke a cigarette, signaling the agent on completion.
The agent then puts out another two of the three ingredients, and the
cycle repeats. Write a program to synchronize the agent and the
smokers.

Request for Question Clarification by maniac-ga on 12 Jun 2003 05:11 PDT
Hello Enm,

This looks like homework, so let me refer you to
  https://answers.google.com/answers/faq.html#homework
which indicates that you should use Google Answers to assist you in
doing the work.

Please also note
  https://answers.google.com/answers/pricing.html
which indicates a $2 question can be answered with a single link or
piece of information. If you are asking for a program to solve this
problem please note that writing such a program will take several
hours and cost far more than $2.

You also place no constraints on the programming language, operating
system, compiler, or time limit on producing an answer. As stated, it
is extremely unlikely for anyone to provide you an acceptable answer.

So, how do you want to proceed? What kind of assistance are you
looking for to produce this program?

  --Maniac
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy