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, 22.06.2019 10:00
Which of the following is true of operations within a spreadsheet program’s built-in functions? a. operations within parentheses, then multiplication and division, and then addition and subtraction are computed. b. operations within parentheses, then addition and subtraction, and then multiplication and division are computed. c. multiplication and division, then addition and subtraction, and then operations within parentheses are computed. d. addition and subtraction, then multiplication and division, and then operations within parentheses are computed
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 22.06.2019 19:10
What a backup plan that you have created in a event you encounter a situation
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
You know the right answer?
The computer science department runs a mentoring center to undergraduate students with their progra...
Questions
question
History, 18.02.2021 14:00
question
Mathematics, 18.02.2021 14:00
question
Mathematics, 18.02.2021 14:00
question
Mathematics, 18.02.2021 14:00
question
Mathematics, 18.02.2021 14:00
question
Physics, 18.02.2021 14:00
Questions on the website: 13722361