1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
gtnhenbr [62]
3 years ago
15

The Sleeping-Barber Problem:

Computers and Technology
1 answer:
s2008m [1.1K]3 years ago
6 0

Answer:

Explanation:

Following are the Semaphores:

Customers: Counts waiting customers;

Barbers: Number of idle barbers (0 or 1)

mutex: Used for mutual exclusion.

Cutting: Ensures that the barber won’t cut another customer’s hair before the previous customer leaves

Shared data variable:

count_cust: Counts waiting customers. ------------copy of customers. As value of semaphores can’t access directly.

// shared data

semaphore customers = 0; semaphore barbers = 0; semaphore cutting = 0; semaphore mutex = 1;

int count_cust= 0;

void barber() {

while(true) { //shop is always open

wait(customers); //sleep when there are no waiting customers

wait(mutex); //mutex for accessing customers1

count_cust= count_cust-1; //customer left

signal(barbers);

signal(mutex);

cut_hair();

}

}

void customer() {

wait(mutex); //mutex for accessing count_cust

if (count_cust< n) {

count_cust= count_cust+1; //new customer

signal(customers); signal(mutex);

wait(barbers); //wait for available barbers get_haircut();

}

else { //do nothing (leave) when all chairs are used. signal(mutex);

}

}

cut_hair(){ waiting(cutting);

}

get_haircut(){

get hair cut for some time; signal(cutting);

}

You might be interested in
are the network administrator for your company. You are installing a new printer in the network. When you check the print server
melamori03 [73]

Answer:

Will have to run the net start spooler command.

Explanation:

  • The printer spooler seems to be accountable for overseeing incoming faxes that have been in effect intended for handling by the printer. Whether this device stops operating, your printer won't publish documentation as well as the machine may not notice it either.
  • To solve these problems, you'll need to run the net start spooler command using the least administrative effort.
5 0
3 years ago
Which tool do you think would be the most useful if you were designing a logo for a business?
Maurinko [17]

Answer:

maybe a computer would be helpful

6 0
3 years ago
Read 2 more answers
in a famous experiment a dog drool at a sound that is made just before meals. This is considered a(n)-------------------- respon
nataly862011 [7]

Answer:

Conditioned response

Explanation:

In a famous experiment a dog drool at a sound that is made just before meals. This is considered a(n) conditioned response.

The dog has been conditioned to respond to the constant sound before his meal is served by drooling(salivating ) with the expectation of eating almost immediately after the sound had been made .

4 0
2 years ago
You speak to a business owner that is taking in almost $2,000 in revenue each month. The owner still says that they’re having tr
Serga [27]
Let's say for example that the business is taking in $2000 of revenue.  That is the amount that the business collected for it's services - like for fixing the computer.  What if though it costs $500 for the equipment (that's an expense).  Now they only made $1500.  Now the customer complains and says that the computer isn't fixed properly so the company sends out a techie for 2 additional hours.  They need to pay their employee (another expense).  Now the $1500 is down to $1400.  They would have utilities to keep their lights on and insurance and many other expenses.

Your profit looks like this:
Profit = Revenue - Expenses
7 0
3 years ago
Kiara is using her software's graphic formats to create a line graph. As she
Ad libitum [116K]

Correct the data she entered , and the software will adjust the graph -apex

5 0
3 years ago
Read 2 more answers
Other questions:
  • To join two or more objects to make a larger whole is to _____________ them.
    8·2 answers
  • Alexei was given a key to a substitution cipher. The key showed that the entire alphabet was rotated 13 steps. What type of ciph
    7·1 answer
  • Ninety-two percent of the new information was stored on magnetic media, mostly in _____.
    11·1 answer
  • Which of the following is a correct definition of the term rectification? A. Rectification is the opposition to current flow in
    14·2 answers
  • Explain the steps users can take to maintain an operating system
    15·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Katy and her associates are approached by an aged tai chi expert to create a website for him. From her participation in an onlin
    9·1 answer
  • If we want to access files located in a directory on a remote server, which of these options would we use?
    9·2 answers
  • 1. You are given a database to create, however, you realize that in the instructions you are told to create relationships betwee
    5·1 answer
  • Tim is a project manager. He is brainstorming with his team about problems that could arise during the next phase of the project
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!