Solved

Barber Problem

Posted on 1998-08-28
3
867 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

Suggested Solutions

Title # Comments Views Activity
Exception thrown at 0x00007FFD5BC81F28 7 60
Error C2678: binary '!=': no operator found... 4 71
boost::uuid crashes 17 61
cmake and message 1 21
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

737 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