Solved

Barber Problem

Posted on 1998-08-28
3
868 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
[X]
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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

705 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