subject

The computer science department runs a mentoring center to undergraduate students with their programming assignments. the lab has a coordinator and several teachers to assist the students. the waiting area of the center has several chairs. initially, all the chairs are empty, the coordinator is waiting for students to arrive and all the teachers are waiting for students to be assigned by coordinator. a student who arrives at the center seeking sits in an empty chair in the waiting area and waits to be called for tutoring. if no chairs are available, the student will come back at a later time. if the coordinator sees a student waiting, then the coordinator wakes up an idle teacher, if there is one, and assigns the student to the teacher. if all the teachers are busy assisting students, the coordinator waits for a teacher to get free and then assigns a waiting student to the teacher. a teacher after assisting a student, waits for the next student to be assigned to him.

using posix threads, mutex locks, and semaphores, implement a solution that coordinates the activities of the coordinator, teachers, and the students. some hints to implement this project are provided next.

implementation hints

using pthreads, begin by creating n students and m teachers as separate threads. (n and m are arguments to the program.) the coordinator will run as a separate thread. student threads will alternate between programming for a period of time and seeking from the teacher. if the teacher is available, they will obtain . otherwise, they will either sit in a chair in the waiting area or, if no chairs are available, will resume programming and seek at a later time.

when a student arrives and finds an empty chair, the student must notify the coordinator using a semaphore. when the teacher is free (initially and after a student), the teacher must notify the coordinator using a semaphore. also, waiting students and teachers must be woken up by the coordinator using separate semaphores.

to simulate students programming in students threads, and the teacher providing to a student in the teacher thread, the appropriate threads should sleep (by invoking for a random of time (up to three seconds).the total number of students, the number of teachers, the number of chairs, and the number of times a student seeks a teacher’s are passed as command line arguments as shown below (csmc is the name of the executable):

csmc #students #teachers #chairs #

csmc 10 3 4 5

once a student thread takes the required number of from the teachers, it should terminate. once all the student threads are terminated, the teacher threads, the coordinator thread, and finally the main program should be terminated.

output

your program must output the following at the appropriate times:

student [#] takes a seat. waiting students = [# of students waiting]

student [#] found no empty chair will try again later

teacher[#] student for [#] seconds. waiting students = [# of students waiting]

grading policy

name your program file as csmc. c/cpp

we need to implement a version of the sleeping barber problem in c++. any would be greatly appreciated!

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:20
This problem has been solved! see the answeran evil king has a cellar containing n bottles of expensive wine, and his guards have just caught a spy trying to poison the king’s wine. fortunately, the guards caught the spy after he succeeded in poisoning only one bottle. unfortunately, they don’t know which one. to make matters worse, the poison the spy used was very deadly; just one drop diluted even a billion to one will still kill someone. even so, the poison works slowly; it takes a full month for the person to die. design a scheme that allows the evil king to determine exactly which one of his wine bottles was poisoned in just one month’s time while expending at most o(logn) of his taste testers.you are not allowed to use n testers, one for each bottle, and see which one tester dies after 30 days.(no pseudocode needed. just answer in words, how many testers you use, how you use them and why you correctly identify the poisoned bottle in 30 days)
Answers: 2
question
Computers and Technology, 21.06.2019 23:30
Step 1: choose your topics review the project milestone reflections you submitted for modules 1 through 4. choose the one major idea or concept from each module that you feel most applies to your life. in addition, choose an important concept from module 5 that applies to your life. step 2: write your guidebook for each module: write a catchy headline that clearly and concisely sums up your chosen idea or concept write a brief explanation that includes a description of the concept, why it is important, and how it can be applied to your life to make a positive impact choose an exciting, powerful, or engaging image that illustrates your concept remember, you are writing one for each module, so you will have a total of five headlines, five descriptions, and five images. step 3: design your guidebook choose a format to present your digital guidebook. there are many 21st century tools available for creating and submitting your work in the online environment. for more information on tools your school uses, contact your instructor or visit the web 2.0 tools area.
Answers: 3
question
Computers and Technology, 22.06.2019 11:10
Which are not examples of chronic or persistent stress? moving
Answers: 1
question
Computers and Technology, 23.06.2019 00:10
My has been slow anyone else’s ?
Answers: 1
You know the right answer?
The computer science department runs a mentoring center to undergraduate students with their progra...
Questions
Questions on the website: 13722360