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
When powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router?
vazorg [7]
<span>the statement that when powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router is false.
The network devices like computers and other peripherals do not have to turned on before turning on the modem, they can be also later turned on.</span>
4 0
3 years ago
The quickbooks online advanced desktop app can be installed on which operating system?.
lorasvet [3.4K]

Explanation:

For Android products, your device will need to be running Nougat 7.1. 1 or newer.

6 0
2 years ago
Which of the following described a global network connecting billions of computers and other
zloy xaker [14]
Pretty sure its wifi
5 0
3 years ago
Read 2 more answers
mips Write a program that asks the user for an integer between 0 and 100 that represents a number of cents. Convert that number
Mumz [18]

Answer:

Explanation:

The following code is written in python and divides the amount of cents enterred in as an input into the correct amount of quarters, dimes, nickels and pennies. Finally, printing out all the values.

import math

#First we need to define the value of each coin

penny = 1

nickel = 5

dime = 10

quarter = 25

#Here we define the variables to hold the max number of each coin

quarters = 0

dimes = 0

nickels = 0

pennys = 0

cents = int(input("Please enter an amount of money you have in cents: "))

if cents > 0 and cents <= 100:

   if cents >= 25:

       quarters = cents / quarter

       cents = cents % quarter

   if cents >= 10:

       dimes = cents/dime

       cents = cents % dime

   if cents >= 5:

       nickels = cents /nickel

       cents = cents % nickel

   if cents > 0:

       pennys = cents / penny

       cents = 0

   print("The coins are: "

       "\nQuarters", math.floor(quarters),

       "\nDimes", math.floor(dimes), "\nNickels", math.floor(nickels), "\nPennies", math.floor(pennys))

else:

   print("wrong value")

8 0
3 years ago
What is the definition for Types of Resource-Community Resources??​
exis [7]
Typically, when someone refers to a community resource, they mean an organization that serves a particular geographical area or group of people by providing tools to help that community grow in positive ways and improve the quality of life for the people of that community.
4 0
3 years ago
Other questions:
  • A short-circuit evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the en
    14·1 answer
  • What is a sluggish beta signal detection theory?
    15·1 answer
  • What does an animation sequence action do?
    12·2 answers
  • Bulleted and Numbered List button appear in the ………….. Toolbar.​
    6·1 answer
  • Given two models applied to a data set that has been partitioned, Model A is considerably more accurate than model B on the trai
    7·1 answer
  • Name the contributions of Steve Jobs and Bill Gates, with respect to technology.
    5·1 answer
  • In which of the following work situations would word processing software be most appropriate to make the task easier?
    6·1 answer
  • Do you get notified if someone follows you on Spotify like your email or do you just have to find out on your own
    14·1 answer
  • Name:
    13·1 answer
  • Why AI strategy is important?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!