Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hiiii every body please i need ur help for the problem of barber sleeping using monitor ( implementation c)
Posted

 
Share this answer
 
Comments
ahmedliver 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
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
 
Share this answer
 
Comments
ahmedliver 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900