Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Barber Problem

Posted on 1998-08-28
3
861 Views
Last Modified: 2009-12-02
I have to implement a solution to the sleeping barber problem using semaphores in Nachos.

The problem I have is that I dont know how to implement an unknown number of semphores in c++. Because the user inputs the number of customers for the barber. And I have to fork that number of threads.
Thanks for all ur help
0
Comment
Question by:pranu
  • 2
3 Comments
 

Author Comment

by:pranu
ID: 1171539
Edited text of question
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1171540
The semaphores will have to be dynamically alocated with "new".  You can allocate a single array of them if you "learn" the number of customers at the start of the program.  Or if the number of customers constantly changes, you can create a linked list or other container to store them.

Let me knoe if you have questions.  
0
 

Author Comment

by:pranu
ID: 1171541
Thanks....I will implement it using the array method...just have to figure out the actual coding..cos I just started learning C++ for this course.

Thanks a lot
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question