?
Solved

Barber Problem

Posted on 1998-08-28
3
Medium Priority
?
871 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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

743 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