Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Linux
hiiii every body please i need ur help for the problem of barber sleeping using monitor ( implementation c)
Posted 27-Dec-11 2:18am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
ahmedliver at 27-Dec-11 8:23am
   
please i just know the solution with semaphore but with monitors no so please i need ur helps for this problmes really it's difficult to find it
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

CLIENT processus [de 1 à N]
{
while (true) {
let_your_hair_grow ();
Barber_Shop.get_haircut call ();
}
}
 
processus de BARBER
{
while (true) {
Barber_Shop.get_next_customer call ();
coupe de cheveux ();
appelez Barber_Shop.finished_cut ();
}

 
suivre Barber_Shop
{
int barbier = 0; # chaise et les variables ouvertes ne sont pas nécessaires
cond barber_available;
cond chair_occupied;
cond door_open;
cond customer_left;
 
get_haircut procédure ()
{
while (Barber == 0) wait (barber_available);
barbier coiffeur = - 1;
Chaise # = 1 chaise;
signal (chair_occupied);
# While (ouvert == 0)
attendre (door_open);
# Open = ouvert -1;
signal (customer_left);
}

get_next_customer procédure ()
{
barbier coiffeur = + 1; signal (barber_available);
# While (chaise == 0)
attendre (chair_occupied);
# = Chaise chaise -1;
}

finished_cut procédure ()
{
# Open = ouvert une;
signal (door_open);
# While (ouvert> 0)
attendre (customer_left);
}
#} Suivre Barber_Shop
  Permalink  
Comments
ahmedliver at 27-Dec-11 8:27am
   
This is my program but i can't do the implementation on c(linux) so no one can give me the implementation in c?????

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 520
1 Maciej Los 290
2 Richard MacCutchan 265
3 BillWoodruff 265
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 27 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100