473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Parallel programming

c++
I need help.

I have to write a pseudocode of this two problems:

- The Sleeping-Barber Problem. A barbershop consists of a waiting room
with n chairs and the barber room containing the barber chair. If there
are no customers to be served, the barber goes to sleep. If a customer
enters the barbershop and all chairs are occupied, then the customer
leaves the shop. If the barber is busy but chairs are available, then
the customer sits in one of the free chairs. If the barber is asleep,
the customer wakes up the barber. Write a program to coordinate the
barber and the customers.

- 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 smokes 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.

I have to use the monitor becouse I can't use the semaphore

Thanks

--
Questa è una firma automatica di MesNews.
Sito: http://www.mesnews.net

Jul 22 '05 #1
8 5482
c++ wrote:
I need help.
What kind?
I have to write a pseudocode of this two problems:
Notice that _you_ have to write it.
- The Sleeping-Barber Problem. A barbershop consists of a waiting room
with n chairs and the barber room containing the barber chair. If there
are no customers to be served, the barber goes to sleep. If a customer
enters the barbershop and all chairs are occupied, then the customer
leaves the shop. If the barber is busy but chairs are available, then
the customer sits in one of the free chairs. If the barber is asleep,
the customer wakes up the barber. Write a program to coordinate the
barber and the customers.

- 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 smokes 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.

I have to use the monitor becouse I can't use the semaphore


OK, _you_ have to use the monitor.

So, what kind of help do you expect?

Try posting to 'comp.programming'. In comp.lang.c++ we deal with C++
_language_ issues. You don't seem to have any. You need help with your
assignment that doesn't concern C++ _at all_. Please choose the right
newsgroup.

V
Jul 22 '05 #2
c++
Scriveva Victor Bazarov sabato, 13/11/2004:
c++ wrote:
I need help.


What kind?
I have to write a pseudocode of this two problems:


Notice that _you_ have to write it.
- The Sleeping-Barber Problem. A barbershop consists of a waiting room with
n chairs and the barber room containing the barber chair. If there are no
customers to be served, the barber goes to sleep. If a customer enters the
barbershop and all chairs are occupied, then the customer leaves the shop.
If the barber is busy but chairs are available, then the customer sits in
one of the free chairs. If the barber is asleep, the customer wakes up the
barber. Write a program to coordinate the barber and the customers.

- 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 smokes 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.

I have to use the monitor becouse I can't use the semaphore


OK, _you_ have to use the monitor.

So, what kind of help do you expect?

Try posting to 'comp.programming'. In comp.lang.c++ we deal with C++
_language_ issues. You don't seem to have any. You need help with your
assignment that doesn't concern C++ _at all_. Please choose the right
newsgroup.

V


I have to write them in c++ oriented pseudo code.

I need the pseudo-code because I don't have any idea of how to wite it!

I have a classwork on it on Monday!

Please, could someone write it for me?

--
Questa è una firma automatica di MesNews.
Sito: http://www.mesnews.net

Jul 22 '05 #3
c++ wrote:
I need help.

I have to write a pseudocode of this two problems:

- The Sleeping-Barber Problem. A barbershop consists of a waiting room
with n chairs and the barber room containing the barber chair. If there
are no customers to be served, the barber goes to sleep. If a customer
enters the barbershop and all chairs are occupied, then the customer
leaves the shop. If the barber is busy but chairs are available, then
the customer sits in one of the free chairs. If the barber is asleep,
the customer wakes up the barber. Write a program to coordinate the
barber and the customers.

- 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 smokes 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.
Ok, so far, so good.
I have to use the monitor becouse I can't use the semaphore


Abd what exactly is now your C++ problem you need help with?

Jul 22 '05 #4
"c++" <mi**********@aliceposta.it> wrote...
[...]
Please, could someone write it for me?


Post the address of your professor and we'll save you the
hassle of submitting your homework.
Jul 22 '05 #5
c++
Rolf Magnus scriveva il 14/11/2004 :
c++ wrote:
I need help.

I have to write a pseudocode of this two problems:

- The Sleeping-Barber Problem. A barbershop consists of a waiting room
with n chairs and the barber room containing the barber chair. If there
are no customers to be served, the barber goes to sleep. If a customer
enters the barbershop and all chairs are occupied, then the customer
leaves the shop. If the barber is busy but chairs are available, then
the customer sits in one of the free chairs. If the barber is asleep,
the customer wakes up the barber. Write a program to coordinate the
barber and the customers.

- 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 smokes 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.


Ok, so far, so good.
I have to use the monitor becouse I can't use the semaphore


Abd what exactly is now your C++ problem you need help with?


I DON'T KNOW ANYTHING ABOUT MONITOR!!!

I study c++ at school in Italy (secondary school) but we haven't alrady
done the OOP but my Systems prof wants us to write this pseudo-code.

Could someone write one of the two problem for me or at least give me
an internet site to study how to implemente a monitor in a computer
programming language?

PS: I tryed to find it on Google, but with no success

--
Questa è una firma automatica di MesNews.
Sito: http://www.mesnews.net

Jul 22 '05 #6
Victor Bazarov wrote:
I have to use the monitor becouse I can't use the semaphore


OK, _you_ have to use the monitor.


Just curious: What's a 'monitor' in this context?
A quick google search didn't show up with something
useful.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #7
Karl Heinz Buchegger wrote:
Victor Bazarov wrote:
I have to use the monitor becouse I can't use the semaphore


OK, _you_ have to use the monitor.

Just curious: What's a 'monitor' in this context?
A quick google search didn't show up with something
useful.


My guess is (and that's off-topic here, AFAIUI) that "the monitor"
is a _single_ mechanism versus semaphores that are _seemingly_
multiple. Essentially, with semaphores the OS acts like a monitor.
One can always implement one's own, disregarding what is available
on one's platform (provided it is in fact available).

V
Jul 22 '05 #8
> Could someone write one of the two problem for me or at least give me
an internet site to study how to implemente a monitor in a computer
programming language?


Can you get any ideas from the discussion "class for function calls
that are not thread safe" for your home work?
http://groups.google.de/groups?threa...amming.threads

Would you like to read this?
- http://en.wikipedia.org/wiki/Monitor
- http://www.home.unix-ag.org/weitzel/threadspp.php

Regards,
Markus
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Yuancai \(Charlie\) Ye | last post by:
Hi, All: I am happy to annouce that we have formally released our latest SocketPro version 4 at www.udaparts.com, an advanced remoting framework written from batching/queue, asynchrony and...
10
by: Joshua Nussbaum | last post by:
I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here. ..NET 2.0 adds the capability...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
9
by: MNQ | last post by:
Hi All I want to use my parallel port of my PC to control some external devices. I am writing a program in ANSI C using the PacificC compiler. What I need to know is how to access the parallel...
3
by: paytam | last post by:
Hi all, Is it possible to write parallel programming in C? I mean for example a simple program like I have a clock on a program that show me current time and and at the same time another job like...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
0
by: fiepye | last post by:
Hello. I am interested in parallel computing in Python. Except other modulesI would like to use new modules for vector and matrix operations and scientific computing SciPy and NumPy. I have...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
3
by: John | last post by:
I have a program that needs to run on a regular basis that looks at a queue table in my database. If there are items in the queue database I need to grab the data from the database and pass it to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.