subject

In an office there is a unisex bathroom with n toilets. The bathroom is open to both men and women, but it cannot be used by men and women at the same time. Develop a concurrent program that simulates the above scenario using semaphores. Your solution should be deadlock free, but it does not have to be starvation free. Note that your program has to implement two functions arriveAtTheBathroom(type) and leaveTheBathroom(type), where type is either MAN or WOMAN

#include ".cpp"
#include

class MyBathroomProblemSolver : public
{
int n;//Number of toilets
public:
MyBathroomProblemSolver(int n)
{
this->n = n;
}
void arriveAtTheBathroom(gender type) override
{
throw std::runtime_error("Not Implemented");
/
*
*
* Your Code goes here
*
*
*
* /
}

void leaveTheBathroom(gender type) override
{
throw std::runtime_error("Not Implemented");
/
*
*
* Your Code goes here
*
*
*
* /
}
};

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:00, MrTeriffic
1. what are the biggest risks when using the public internet as a wide area network (wan) or transport for remote access to your organization’s it infrastructure?
Answers: 2
image
Computers and Technology, 22.06.2019 06:00, willowcollins3753
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
image
Computers and Technology, 24.06.2019 02:50, rurbanok12
Be sure to answer all parts. synthesize the following compound from benzene. a. b. c. d. e. f. reaction [1] conditions: a b c d e f reaction [1] product: draw structure reaction [2] conditions: a b c d e f reaction [2] product: draw structure reaction [3] conditions: a b c d e f reaction [3] product:
Answers: 3
image
Computers and Technology, 24.06.2019 17:30, KaleahV
List at least one thing to check for when you're checking the clarity and professionalism of a document.
Answers: 1
You know the right answer?
In an office there is a unisex bathroom with n toilets. The bathroom is open to both men and women,...

Questions in other subjects: