Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve this problem in Java Threads and Semaphores Design the following 2 things (1) a list of every semaphore, its purpose, and its initial value,

Solve this problem in Java

Threads and Semaphores

Design the following 2 things

(1) a list of every semaphore, its purpose, and its initial value,

(2) pseudocode for each function. The pseudocode should be similar to the pseudocode shown in the textbook for the barbershop problem. Every wait and signal call must be included in the pseudocode.

Overview: The clinic to be simulated has doctors, each of which has their own nurse. Each doctor has an office of his or her own in which to visit patients. Patients will enter the clinic to see a doctor, which should be randomly assigned. Initially, a patient enters the waiting room and waits to register with the receptionist. Once registered, the patient sits in the waiting room until the nurse calls. The receptionist lets the nurse know a patient is waiting. The nurse directs the patient to the doctors office and tells the doctor that a patient is waiting. The doctor visits the patient and listens to the patients symptoms. The doctor advises the patient on the action to take. The patient then leaves. Threads://number of patient and doctors should be command line inputs

Receptionist one thread

Doctor one thread each, maximum of 3 doctors

Nurse one per doctor thread, identifier of doctor and corresponding nurse should match

Patient one thread each, up to 30 patients

Other rules:

A thread should sleep 1 second at each step the thread prints an activity.

All mutual exclusion and coordination must be achieved with semaphores.

A thread may not use sleeping as a means of coordination.

Busy waiting (polling) is not allowed.

Mutual exclusion should be kept to a minimum to allow the most concurrency.

Each thread should only print its own activities. The patient threads prints patient actions and the doctor threads prints doctor actions, etc.

Your output must include the same information and the same set of steps as the sample output.

Output

Each step of each task of each thread should be printed to the screen with identifying numbers so it is clear which threads are involved.

Begin by printing the number of patients, nurses, and doctors in this run.

Thread activity output sample. Your output should contain the same set of steps per thread:

Run with 3 patients, 3 nurses, 3 doctors

Patient 0 enters waiting room, waits for receptionist

Receptionist registers patient 0

Patient 0 leaves receptionist and sits in waiting room

Patient 2 enters waiting room, waits for receptionist

Nurse 0 takes patient 0 to doctor's office

Receptionist registers patient 2

Patient 0 enters doctor 0's office

Patient 2 leaves receptionist and sits in waiting room

Patient 1 enters waiting room, waits for receptionist

Nurse 2 takes patient 2 to doctor's office

Receptionist registers patient 1

Patient 2 enters doctor 2's office

Doctor 0 listens to symptoms from patient 0

Patient 1 leaves receptionist and sits in waiting room

Patient 0 receives advice from doctor 0

Doctor 2 listens to symptoms from patient 2

Patient 2 receives advice from doctor 2

Nurse 1 takes patient 1 to doctor's office

Patient 1 enters doctor 1's office

Doctor 1 listens to symptoms from patient 1

Patient 1 receives advice from doctor 1

Patient 0 leaves

Patient 2 leaves

Patient 1 leaves

.

.

.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

Identify and explain three models of management ethics.

Answered: 1 week ago

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago

Question

Describe what a one-minute self-sell is and what it contains.

Answered: 1 week ago

Question

List and explain the steps in the negotiating process.

Answered: 1 week ago