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
A(n) ____________ is special high-speed memory that allows a microprocessor to access data more rapidly than from memory located
iren [92.7K]

Answer is CPU cache

Explanation: A CPU cache is a special high-speed memory which is smaller and faster, and which helps to store copies of data from main memory location which are often used. It is actually located quite close to the processing core, and is used by the CPU of a computer to save time and energy in accessing data from the main memory.

The way it works is if the processor is either trying to read from or write to a particular location in the main memory, it checks to see if the data from the location is already in a cache, if it is, then it alternatively read from or write to the cache; which faster, instead of the main memory.

Please let me know if this helps.

7 0
3 years ago
Read 2 more answers
Jamal is a graphic designer.a. What hardware tool would you suggest for his computing system? Include an explanation and the cos
Schach [20]

Answer:

Mac computer is the correct answer for option "a" in this question.

Adobe flash is the correct answer for option "b" in this question.

Mac OS  is the correct answer for option "c" in this question.

Explanation:

  • Hardware: Graphic designers must use Mac computers for the best graphic designing.

They support many of the software programs, graphic designers use. Whether the graphic designer chooses Mac or PC, it is important that the computer have a fast processing speed, large amount of hard drive storage and large monitor.

  • <u><em>Cost:</em></u> Approx $5999
  • Software:  Graphic designers must use Adobe flash for the best graphic designing.

Adobe flash help designers easily take graphic design to the Web using basic HTML language.It also helps in motion graphics,web designing etc.

  • <u><em>Cost:</em></u> Adobe Flash is free to install and use. Adobe Flash editing software starts at $99.
  • Operating system: Graphic designers must use Mac OS for the best graphic designing. Mac OS supports most of the software programs and  it inspired Microsoft Corporation to develop its own GUI.
  • <u><em>Cost:</em></u> The current version of Mac OS X costs $29.99 from the Mac's App Store.

3 0
4 years ago
Which of the following is an advantage to using internal databases for​ information? A. Internal information is accurate and com
Irina-Kira [14]

Answer:

C. They can be accessed quickly and cheaply.

Explanation:

An internal database is information that can be obtained inside the company through internal networks. This information can be easy to get as it is in the network of the company and you have access to it and it also have a low cost as you don't have pay money to get it. According to this, the answer is that an advantage to using internal databases for​ information is that they can be accessed quickly and cheaply.

The other options are not right because internal information can be  outdated and incomplete if it is not updated by people in the company and it can be found in different forms and it is not always easy to manage as this depends on the applications used and how the company decides to visualize it.

3 0
3 years ago
Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
MA_775_DIABLO [31]

Answer:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    const int NUM_VALS = 4;
  6.    int hourlyTemp[NUM_VALS];
  7.    int i;
  8.    
  9.    for (i = 0; i < NUM_VALS; ++i)
  10.    {
  11.        cin >> hourlyTemp[i];
  12.        
  13.    }
  14.    
  15.    /* Your solution goes here */
  16.    for(i = 0; i < NUM_VALS; ++i){
  17.        
  18.        if(i < NUM_VALS -1){
  19.            cout<<hourlyTemp[i]<<",";
  20.        }
  21.        else{
  22.            cout<<hourlyTemp[i];
  23.        }
  24.    }
  25.    cout << endl;
  26.    return 0;
  27. }

Explanation:

The solution code is given from Line 18 - 26. To print the element from array one after another, we create a for loop to traverse through every element in the array (Line 18). Create an if condition to check if the current index i is not the last index, print the element followed with a comma (Line 20 -22). Otherwise print only the element (Line 23 - 25).

8 0
3 years ago
Read the four detective reports and the combined affidavit and warrant for the M57 Patents case. Write a one- to two-page paper
Fantom [35]

Answer:The 2009-M57-Patents scenario tracks the first four weeks of corporate history of the M57 Patents company. The company started operation on Friday, November 13th, 2009, and ceased operation on Saturday, December 12, 2009. As might be imagined in the business of outsourced patent searching, lots of other activities were going on at M57-Patents.

Two ways of working the scenario are as a disk forensics exercise (students are provided with disk images of all the systems as they were on the last day) and as a network forensics exercise (students are provided with all of the packets in and out of the corporate network). The scenario data can also be used to support computer forensics research, as the hard drive of each computer and each computer’s memory were imaged every day.

Explanation:

4 0
3 years ago
Other questions:
  • What are the five types of alignment in word?
    8·2 answers
  • In a class hierarchy,
    15·1 answer
  • Unlocking your smart phone remote security protections that protect your mobile device from meniscus applications
    5·1 answer
  • Jenna wants to convert a decimal number to its octal form. Which option will she use to calculate the octal number?
    8·1 answer
  • A company is updating their office routers that handle all incoming and outgoing networking traffic. They would like the PCs to
    10·1 answer
  • How many four-digit personal identification numbers (PIN) are possible if the PIN cannot begin or end with a 0 and the PIN must
    6·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    15·2 answers
  • True or false: It can take some time for the labs to load once you click “start lab.”
    7·1 answer
  • What are some of the ways we can resolve IPv4 address shortages? Check all that apply.
    13·1 answer
  • Why is it important to think about the programming language to use?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!