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: 19 days ago.Category: Homework
Show More
Show Less
Ask Your Own Homework Question
Customer reply replied 19 days 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 18 days 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 18 days ago
Let me know if you need more information, or send me the service offer(s) so we can proceed.
Customer reply replied 16 days ago
This question was now answered. I would like a refund on the question
Customer reply replied 16 days ago
not
Answered in 3 days by:
4/3/2018
Tutor: George Sibiya, Computer Hardware Engineer replied 16 days ago
George Sibiya
George Sibiya, Computer Hardware Engineer
Category: Homework
Satisfied Customers: 287
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 16 days 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?
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,731 satisfied customers

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

Manal Elkhoshkhany

Manal Elkhoshkhany

Tutor

4,551 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,636 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,161 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
Drawings that depict existing conditions are often marked
Drawings that depict existing conditions are often marked with A. blue lines indicating future expansion plans. B. the term "graphic FACP required." C. the term "as-built." D. a symbols legend.… read more
F. Naz
F. Naz
Chartered Accountant
CA Finalist & Completed B.com
2,161 satisfied customers
Exam Results Technology Orientation, Part 1 Exam Number
Exam ResultsTechnology Orientation, Part 1 Exam Number 062005RR Grade 65 Date Graded 04/15/18 Question Number Your Answer Answer Reference 1. C Correct 2. C D PAGE 42 3. D C PAGE 66 4. C A PAGE 10 5. … read more
Chris M.
Chris M.
M.S.W. Social Work
Master's Degree
2,636 satisfied customers
I very new to programming. I am working on a uni assignment.
I very new to programming. I am working on a uni assignment. And I stuck on one part of my code. I have been trying to fix it for 4 hours, and I cant figure it out … read more
Ingo U
Ingo U
Master\u0027s Degree
358 satisfied customers
Glenn, Attached you can see the new assignment. Due in three
Hi Glenn, Attached you can see the new assignment. Due in three days. Let me know if it is clear… read more
GLENN
GLENN
Master of Mathematics
389 satisfied customers
I have a javascript assignment that I am having
good evening I have a javascript assignment that I am having complications understanding what she is requesting for us to do … read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,731 satisfied customers
Trying to come up with 3 sociological concepts in the movie
trying to come up with 3 sociological concepts in the movie This is 40 and example of each from movie … read more
GLENN
GLENN
Master of Mathematics
389 satisfied customers
Looking for Microeconimics help. K. Mo
Looking for Microeconimics help JA: The Tutor can help you get an A on your homework or ace your next test. Tell us more about what you need help with so we can help you best. Customer: k JA: Is there… read more
F. Naz
F. Naz
Chartered Accountant
CA Finalist & Completed B.com
2,161 satisfied customers
1. Why does Pumblechook choke on the brandy at Christmas
1. Why does Pumblechook choke on the brandy at Christmas dinner? A. He becomes overexcited telling his story. B. Mrs. Joe had only spoiled brandy to serve him. C. He has had too much to drink. D. Pip … read more
Chris M.
Chris M.
M.S.W. Social Work
Master's Degree
2,636 satisfied customers
Case Study 1: Keylogger Scam Read the article titled:
Case Study 1: Keylogger ScamRead the article titled: “Police Foil $420 Million Keylogger Scam” found on the eWeek.com Website located at http://www.eweek.com/c/a/Security/Police-Foil-420-Million-Keylo… read more
GLENN
GLENN
Master of Mathematics
389 satisfied customers
I need it in c++ It is in the link
https://fgamedia.org/faculty/anand/cs2c/labs/2C.Lab-02-Spec-SparseMats.pdfhttps://fgamedia.org/faculty/anand/cs2c/modules/cs_2C_2b_7.html I need it in c++ … read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,731 satisfied customers
This question is about MRI's and their usefulness. If a
Hi. This question is about MRI's and their usefulness. If a neuroanatomist gets the anatomy wrong about a specific white matter tract of the brain, let's use the superior occipitofrontal fasciculus as… read more
Dr. Mark
Dr. Mark
M.D. in Neurosurgery
Doctoral Degree
5,370 satisfied customers
You did an awesome job last time, decided to come back. The
Hey LogicPro, you did an awesome job last time, decided to come back. The assignments is due Saturday, thanks… read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,731 satisfied customers
C Programming Language Write a main function that include
C Programming Language Write a main function that include these operations:a) ask for an integer and output whether the entered number is ***** or net. b) ask for two floats and outputs the largest of… read more
Ingo U
Ingo U
Master\u0027s Degree
358 satisfied customers
ForLogicPro Only", Developing a well committed C++ program
quot;ForLogicPro Only", Developing a well committed C++ program in Visual Studio 2017 that implements the Hashtable functions and follows the directions/grading rubric within the provided PDF.… read more
LogicPro
LogicPro
Engineer
Bachelor of Technology
5,731 satisfied customers
I need help with my math project. Let me copy and past the
(LR-1) Describe your topic, provide your data, and cite your source. Collect at least 8 data points. Label appropriately. (Highly recommended: Post this information in the Linear Model Project discussion as well as in your completed project. Include a brief informative description in the title of your posting. Each student must use different data.) The idea with the discussion posting is two-fold: (1) To share your interesting project idea with your classmates, and (2) To give me a chance to give you a brief thumbs-up or thumbs-down about your proposed topic and data. Sometimes students get off on the wrong foot or misunderstand the intent of the project, and your posting provides an opportunity for some feedback. Remark: Students may choose similar topics, but must have different data sets. For example, several students may be interested in a particular Olympic sport, and that is fine, but they must collect different data, perhaps from different events or different gender. (LR-2) Plot the points (x, y) to obtain a scatterplot. Use an appropriate scale on the horizontal and vertical axes and be sure to label carefully. Visually judge whether the data points exhibit a relatively linear trend. (If so, proceed. If not, try a different topic or data set.) (LR-3) Find the line of best fit (regression line) and graph it on the scatterplot. State the equation of the line. (LR-4) State the slope of the line of best fit. Carefully interpret the meaning of the slope in a sentence or two. (LR-5) Find and state the value of r2, the coefficient of determination, and r, the correlation coefficient. Discuss your findings in a few sentences. Is r positive or negative? Why? Is a line a good curve to fit to this data? Why or why not? Is the linear relationship very strong, moderately strong, weak, or nonexistent? (LR-6) Choose a value of interest and use the line of best fit to make an estimate or prediction. Show calculation work. (LR-7) Write a brief narrative of a paragraph or two. Summarize your findings and be sure to mention any aspect of the linear model project (topic, data, scatterplot, line, r, or estimate, etc.) that you found particularly important or interesting. You may submit all of your project in one document or a combination of documents, which may consist of word processing documents or spreadsheets or scanned handwritten work, provided it is clearly labeled where each task can be found. Be sure to include your name. Projects are graded on the basis of completeness, correctness, ease in locating all of the checklist items, and strength of the narrative portions.… read more
GLENN
GLENN
Master of Mathematics
389 satisfied customers
In the correlation coefficient formula to find the r-value,
in the correlation coefficient formula to find the r-value, I have substituted all of my values, but I don't know what to do with the two square roots in the denominator. Can someone help?… read more
GLENN
GLENN
Master of Mathematics
389 satisfied customers
1. Which of the following is not a condition under which the
1. Which of the following is not a condition under which the malfunction indicator light (MIL) or service engine light is turned off? A. Criteria for the PCM to clear codes is reached B. Vehicle batte… read more
Chris M.
Chris M.
M.S.W. Social Work
Master's Degree
2,636 satisfied customers
1)outline a brief history of the occupational safety and
1)outline a brief history of the occupational safety and health act (OSHA). What was the political atmosphere when OSH was signed into law? What were the basic provisions of the bill? How effective ha… read more
judybailey61
judybailey61
Bachelors degree
196 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