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
Where could an identity theft access your personal information?
Naily [24]
They can hack into you email or your phone number thats all they need to find where you live how old you are and etc hope this helps

8 0
2 years ago
Read 2 more answers
The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
kolbaska11 [484]

Answer:

Dynamic packet-filtering firewall.            

Explanation:

Packet filtering is basically a technique of scanning and filtering the network data packets. This technique allows or disallows the network packets to enter through the firewall or to transmit from one network to the other. Dynamic packet filtering packet-filtering firewall allows only a particular packet with a particular source, destination, and port address to enter through the firewall. It utilizes the information in packet header and inspects and utilizes active connections state information. This information enables to decide which packet should enter through the firewall.

8 0
3 years ago
Spark is electrical discharge in air, while air is mix of variety of gases what particles conduct electricity in gas
erastova [34]

Answer:

Mercury, rontgen rays, etc.

Explanation:

There are lots of answers to this question, hope these two help.

6 0
2 years ago
Is the process of modifying something to make it fit certain criteria.
alexandr402 [8]

Answer:

Design Process

8 0
2 years ago
What is the numerical ratio that is equivalent to 19.2 dB?
mrs_skeptik [129]

Answer: 83.17

Explanation:

By definition, the dB is an adimensional unit, used to simplify calculations when numbers are either too big or too small, specially in telecommunications.

It applies specifically to power, and it is defined as follows:

P (dB) = 10 log₁₀ P₁ / P₂

Usually P₂ is a reference, for instance, if P₂ = 1 mW, dB is called as dBm (dB referred to 1 mW), but it is always adimensional.

In our question, we know that we have a numerical ratio, that is expressed in dB as 19.2 dB.

Applying the dB definition, we can write the following:

10 log₁₀ X = 19.2 ⇒ log₁₀ X = 19.2 / 10 = 1.92

Solving the logarithmic equation, we can compute X as follows:

X = 10^1.92  = 83.17

X = 83.17

4 0
2 years ago
Other questions:
  • What two programming systems uses numbers and text?
    6·1 answer
  • Write a program that lets the user enter a nonnegative integer then uses a loop to calculate the factorial of that number. Displ
    11·1 answer
  • A write once, read many (worm) disc is a common type of _____.
    6·1 answer
  • Which of the following Web sites would be MOST credible?
    6·1 answer
  • If you want to insert a column into an existing table, what would you do?
    13·2 answers
  • Different between desktop application and web application ?​
    9·1 answer
  • What do macOS and Windows use to prevent us from accidentally deleting files?
    15·1 answer
  • if anyone is on a Chromebook, do you ever mean to press backspace, then you accidentally press the power button and think "OH CR
    11·2 answers
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
  • ____ characterized the period now known a Web 1. 0. Augmented reality
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!