Parallel programming

Discussion in 'C++' started by c++, Nov 13, 2004.

  1. c++

    c++ Guest

    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
     
    c++, Nov 13, 2004
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Nov 13, 2004
    #2
    1. Advertising

  3. c++

    c++ Guest

    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
     
    c++, Nov 13, 2004
    #3
  4. c++

    Rolf Magnus Guest

    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?
     
    Rolf Magnus, Nov 13, 2004
    #4
  5. "c++" <> 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.
     
    Victor Bazarov, Nov 14, 2004
    #5
  6. c++

    c++ Guest

    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
     
    c++, Nov 14, 2004
    #6
  7. 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
     
    Karl Heinz Buchegger, Nov 15, 2004
    #7
  8. 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
     
    Victor Bazarov, Nov 15, 2004
    #8
  9. > 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?thre...ing.google.com&group=comp.programming.threads

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

    Regards,
    Markus
     
    Markus Elfring, Nov 15, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. karthik
    Replies:
    5
    Views:
    11,048
    Dale King
    Jul 25, 2003
  2. Paul Perrone
    Replies:
    0
    Views:
    14,482
    Paul Perrone
    Aug 21, 2003
  3. Soren
    Replies:
    4
    Views:
    1,321
    c d saunter
    Feb 14, 2008
  4. Vivek Menon
    Replies:
    5
    Views:
    3,468
    Paul Uiterlinden
    Jun 8, 2011
  5. Vivek Menon
    Replies:
    0
    Views:
    1,795
    Vivek Menon
    Jun 10, 2011
Loading...

Share This Page