Homework

Homework Questions? Ask a Tutor for Answers ASAP

Ask an Expert,
Get an Answer ASAP!

Mind helping me with this program? Due Date: Saturday, March…

Customer Question
Hey ******* Mind helping me...

Hey ******* Mind helping me with this program? Due Date: Saturday, March 31, 2018 I. Project Organization This project will study the coordination of multiple threads using semaphores. You should do the following pieces to complete your project. Each piece is explained below: • Design 40 points • Code 25 points • Output 25 points • Summary 10 points Design The design should consist of two things: (1) a list of every semaphore, its purpose, and its initial value, and (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. Code Your code should be nicely formatted with plenty of comments. The code should be easy to read, properly indented, employ good naming standards, good structure, and should correctly implement the design. Your code should match your pseudocode. Output Output will be graded by running your program. Summary The summary section should discuss your simulation, any difficulties encountered, what was learned, and results. It should be at least one page in length. II. Project Description Language/Platform This project must target a Unix platform and execute properly on our cs1 or csgrads1 Linux server. The project must be written in C, C++, or Java. If using C or C++, you must use POSIX pthreads and semaphores. If using Java, you must use Java Threads and Java Semaphores (java.util.concurrent.Semaphore). You should not use the “synchronized” keyword in Java. You should not use any Java classes that have built-in mutual exclusion. Any mechanisms for thread coordination other than the semaphore are not allowed. Doctor’s Office Simulation This project will simulate a visit to the doctor’s office. It is similar to the “barbershop” example in the textbook. 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 doctor’s office and tells the doctor that a patient is waiting. The doctor visits the patient and listens to the patient’s symptoms. The doctor advises the patient on the action to take. The patient then leaves. Threads 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 Inputs The program should receive the number of doctors and patients as command-line inputs. Other rules: 1) A thread should sleep 1 second at each step the thread prints an activity. 2) All mutual exclusion and coordination must be achieved with semaphores. 3) A thread may not use sleeping as a means of coordination. 4) Busy waiting (polling) is not allowed. 5) Mutual exclusion should be kept to a minimum to allow the most concurrency. 6) Each thread should only print its own activities. The patient threads prints patient actions and the doctor threads prints doctor actions, etc. 7) Your output must include the same information and the same set of steps as the sample output.   Output 1) 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. 2) Begin by printing the number of patients, nurses, and doctors in this run. 3) 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 . . .   III. Project Guidelines Submitting Your final project should work correctly on cs1 or csgrads1. Submit your project on eLearning. Include in your submission the following files: 1) ‘design.xxx’ where xxx is doc, docx, or pdf. 2) ‘summary.xxx’ where xxx is doc, docx, or pdf. 3) ‘project2.c’, ‘project2.cpp’, or ‘Project2.java’ along with any other source files. 4) ‘readme.txt’ containing: a) the complete command line used to compile your program b) the complete command line used to run your program c) any other details the TA should know Partial or Missing Submissions It is your responsibility to upload all of the right files on time. It is recommended that you double-check the files you upload to make sure they are the right ones. Once the deadline passes, changes to the submission are not accepted without a late penalty. Academic Honesty This is an individual project. All work must be your own. Comparison software may be used to compare the work of all students. Similar work will be reported to the Office of Judicial Affairs for investigation. Grading The written portions will be graded subjectively based on completeness and quality. The code will be graded based on points allocated for each key part of the processing as determined by the instructor. The output will be graded based on expected results. Resources The web has many articles on threads and there are books available on threads. The course website also contains example source code.

Submitted: 2 months ago.Category: Homework
Show More
Show Less
Ask Your Own Homework Question
Customer reply replied 2 months ago
Include libraries
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.*;//Define a classpublic class Project2 {
//Define a class
class syncData {
//Declare variables
public Semaphore patientSem;
public Semaphore receptionistSem;
public Semaphore nursesSem;
public int maxPatients;
public int numOfPatients = 0;
public Lock mtx1;
public int patientID;
public Queue <Integer> patientQueue;
public Lock mtx2;
public int patientCheckedIn;
public int numOfNurses;
public int numOfDoctors;
//Define constructor
syncData(int value) {
patientSem = new Semaphore(0);
receptionistSem = new Semaphore(0);
nursesSem = new Semaphore(0);
mtx1 = new ReentrantLock();
mtx2 = new ReentrantLock();
maxPatients = value;
patientQueue = new LinkedList < Integer > ();
patientCheckedIn = 0;
}
}
//Define class
class Receptionist extends Thread {
//Create instance
boolean busy;
syncData sync;
//Define a constructor
public Receptionist(syncData s) {
//Assign value
busy = false;
sync = s;
}
public void run() {
for (int i = 0; i < sync.numOfPatients; i++) {
try {
sync.patientSem.acquire();
} catch (InterruptedException lE) {}
sync.mtx1.lock();
//increment
sync.maxPatients++;
sync.receptionistSem.release();
sync.mtx1.unlock();
try {
Thread.sleep(20);
} catch (InterruptedException lE) {}
}
}
}
//Define a class
class Patient extends Thread {
//Declare variable
int patientNo;
//Declare variable
boolean isWaiting;
//Declare variable
syncData sync;
//Define constructor
public Patient(int value, syncData s) {
//Assign value
patientNo = value;
isWaiting = false;
sync = s;
}
//Define method
public void run() {
//Display message
System.out.println("Patient " + patientNo + " enters waiting room, waits for receptionist.");
//Call method
sync.mtx1.lock();
//If condition satisfies
if (sync.maxPatients > 0) {
//Decrement
--sync.maxPatients;
//Call method
sync.patientSem.release();
sync.mtx1.unlock();
try {
//Call method
sync.receptionistSem.acquire();
} catch (InterruptedException lE) {}
System.out.println("Receptionist registers patient " + patientNo);
try {
Thread.sleep(20);
} catch (InterruptedException lE) {}
System.out.println("Patient " + patientNo + " leaves receptionist and sits in waiting room");
//Increment
sync.patientCheckedIn++;
//Call method
sync.patientQueue.add(patientNo);
//Assign value
isWaiting = true;
}
//Stop
Thread.currentThread().stop();
}
}
//Define class
class Nurse extends Thread {
//Declare variable
int nurseNo;
boolean isBusy;
syncData sync;
public Nurse(int value, syncData s) {
//Assign value
nurseNo = value;
//Assign value
isBusy = false;
//Assign value
sync = s;
}
//Define method
public void run() {
//Lock
sync.mtx2.lock();
//If condition satisfies
if (!sync.patientQueue.isEmpty()) {
//Assign value
Integer patientNo = sync.patientQueue.remove();
//Decrement
--sync.patientCheckedIn;
//Call method
sync.mtx2.unlock();
//Try
try {
//Sleep
Thread.sleep(20);
}
//Catch
catch (InterruptedException lE) {}
//Display message
System.out.println("Nurse " + nurseNo + " takes patient " + patientNo + " to doctor's office");
//Assign value
isBusy = true;
}
//Call method
Thread.currentThread().stop();
}
}
Customer reply replied 2 months ago
Posted by JustAnswer at customer's request) Hello. I would like to request the following Expert Service(s) from you: Live Phone Call.
Customer reply replied 2 months ago
Let me know if you need more information, or send me the service offer(s) so we can proceed.
Customer reply replied 2 months ago
This question was now answered. I would like a refund on the question
Customer reply replied 2 months ago
not
Answered in 3 days by:
4/3/2018
Tutor: George Sibiya, Computer Hardware Engineer replied 2 months ago
George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Homework
Satisfied Customers: 358
Experience: PhD in Computer Science
Verified

Hi,

Welcome to JustAnswer and thank you for utilizing our service.

Apologies for the long wait.

Just for clarity on the "not", do you still need help on it or you got it resolved?

Regards,

G

Ask Your Own Homework Question
Customer reply replied 2 months ago
Just to clarify, I managed to get it resolved myself. But I do appreciate the help. I will use this for future use. However, may I have a refund for this transaction?
Thank you
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a tutorLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask Scott Your Own Question
Scott
Scott
Scott, MIT Graduate
Category: Homework
Satisfied Customers: 3,040
3,040 Satisfied Customers
Experience: MIT Graduate (Math, Programming, Science, and Music)

Scott is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.

DianeDallas, TX

< Previous | Next >

Meet the Experts:

LogicPro

LogicPro

Engineer

5,867 satisfied customers

Expert in Java C++ C C# VB Javascript Design SQL HTML

Manal Elkhoshkhany

Manal Elkhoshkhany

Tutor

4,556 satisfied customers

More than 5000 online tutoring sessions.

Linda_us

Linda_us

Finance, Accounts & Homework Tutor

3,138 satisfied customers

Post Graduate Diploma in Management (MBA)

Chris M.

Chris M.

M.S.W. Social Work

2,698 satisfied customers

Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

F. Naz

F. Naz

Chartered Accountant

2,190 satisfied customers

Experience with chartered accountancy

Bizhelp

Bizhelp

CPA

1,887 satisfied customers

Bachelors Degree and CPA with Accounting work experience

Seanna

Seanna

Tutor

1,781 satisfied customers

3,000+ satisfied customers, all topics, A+ work

< Previous | Next >

Related Homework Questions
JAVA] Add capability to given program to handle Grade Book
JAVA] Add capability to given program to handle Grade Book for different subjects (Chemistry and Computer Science). We will assume a maximum of five assignments and up to 40 students.… read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,867 satisfied customers
Need help with my home work. Python. Learn as well as get my
need help with my home work JA: Is there a specific language you're coding in? Customer: yes python JA: What's your objective for this Python project? Customer: learn as well as get my homeworks done … read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,867 satisfied customers
Question #1 A statics professor plans class so carefully
quot;For Sandhya" Question #1 A statics professor plans class so carefully that the lengths of her classes are uniformly distributed between 47.0 and 57.0 minutes. Find the probability that a given cl… read more
Sandhya_sharma
Sandhya_sharma
Master\u0027s Degree
560 satisfied customers
Due Friday by 11:59pm NAME nfa2dfa - deterministic finite
Due Friday by 11:59pm NAME nfa2dfa - deterministic finite automaton checkSYNOPSIS nfa2dfa nfafileSPECIFICATION A nondeterministic finite automaton is defined as five tuple M = (Q,S,F,q0,δ) where: • Q … read more
Bruce Wilner
Bruce Wilner
Master of Engineering
29 satisfied customers
My calculations (see uploaded spreadsheet) do exactly what I
My calculations (see uploaded spreadsheet) do exactly what I want. My problem is controlling what the user sees. I want different portions of the worksheet to appear or disappear, depending upon choic… read more
GLENN GILONGOS
GLENN GILONGOS
Master of Mathematics
418 satisfied customers
I need answers to my homework questions and I need to submit
I need answers to my homework questions and I need to submit by today 11:59 pm and I am looking for help. I really need this cause I am way behind in assignments. … read more
Sandhya_sharma
Sandhya_sharma
Master\u0027s Degree
560 satisfied customers
For LogicPro only Purpose: Use a Priority_queue to simulate
For LogicPro onlyPurpose: Use a Priority_queue to simulate a Binary_TreeTechniques/Structures: Polymorphism, SmartPointers, Priority_Queue, LambdasStep1: Create a frequency table of ascii characters b… read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,867 satisfied customers
1. If a 2:1 transformer has a 220 VAC input, a voltage test
1. If a 2:1 transformer has a 220 VAC input, a voltage test at the primary winding should produce a meter reading of A. 0 VAC. B. 110 VAC. C. 220 VAC. D. 440 VAC. 2. A circuit contains four 100 Ω resi… read more
Sandhya_sharma
Sandhya_sharma
Master\u0027s Degree
560 satisfied customers
The project consist of a set of data with three independent
The project consist of a set of data with three independent questions.1. Create a histogram or bar graph for some variable categorized by age and split for men and women. This extends the idea of bar … read more
GLENN GILONGOS
GLENN GILONGOS
Master of Mathematics
418 satisfied customers
Create an Io program that duplicates the Java example
For Logic Pro onlyCreate an Io program that duplicates the Java example SortedList.java, in both functionality and object-oriented design It is assumed that your program can be run like this: io Sorte… read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,867 satisfied customers
I need this Project Answer by 6:00 pm today June 19 2018,
I need this Project Answer by 6:00 pm today June 19 2018, and I would like to be notified if a writer would take the question. If Writer Grace is available I would like her if not anyone can take it.U… read more
GLENN GILONGOS
GLENN GILONGOS
Master of Mathematics
418 satisfied customers
I need answers for my associates accounting exams,
Hi JA: Hello. How can I help? Customer: I need answers for my associates accounting exams JA: The Tutor can help you get an A on your homework or ace your next test. Tell me more about what you need h… read more
Manal Elkhoshkhany
Manal Elkhoshkhany
Tutor
4,556 satisfied customers
What is the answer? Nonparametric statistics requires a
What is the answer ? Nonparametric statistics requires a larger sample size because of ? a. Sensivity B.range of scores C.variance D.power… read more
GLENN GILONGOS
GLENN GILONGOS
Master of Mathematics
418 satisfied customers
I have a requirement to write an Oracle PL/SQL code to
I have a requirement to write an Oracle PL/SQL code to delete about 9 billion records in small batches of 10,000. The procedure should run quasi permanently (loop/sleep) and must backup (log/copy) the… read more
Chris Baxter
Chris Baxter
28 satisfied customers
I need help creating an excel formula (i'm assuming an IF or
I need help creating an excel formula (i'm assuming an IF or SUM IF) where certain pick list values need to be selected across columns B-N of my sheet in order to return a YES, NO, or TBD answer in co… read more
The-PC-Guy
The-PC-Guy
Bachelor\u0027s Degree
630 satisfied customers
I have a written code for C++ for the lottery. I have I
Hello, I have a written code for C++ for the lottery … read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,867 satisfied customers
Random and independent samples of 85 recent prime time
Random and independent samples of 85recent prime time airings from each of two major networks have been considered. The first network aired a mean of 110.7commercials during prime time, with a standar… read more
Sandhya_sharma
Sandhya_sharma
Master\u0027s Degree
560 satisfied customers
This question in only for Teacher Keys! Could you please
This question in only for Sarah TeacherKeysHi, Sarah! Could you please help me find the blank models for the two keys I'm going to indicate ? Photos are attachedThe squared key says 1c arrow. If you h… read more
Sarah
Sarah
Teacher
Master\u0027s Degree
19 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x