Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We are supposed to write the program in C++ and we are told that the project is a modification of the sleeping barber (TA) problem
We are supposed to write the program in C++ and we are told that the project is a modification of the sleeping barber (TA) problem which the solution for is available online.
Any help would be great!
king Tutor Problem The computer science department runs a mentoring center to help undergraduate students with their programming assignments. The lab has a coordinator and several tutors 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 tutors are waiting for students to be assigned by coordinator. A student who arrives at the center seeking help 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 tutor, if there is one, and assigns the student to the tutor. If all the tutors are busy assisting students, the coordinator waits for a tutor to get free and then assigns a waiting student to the tutor. A tutor 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, tutors, and the students. Some hints to implement this project are provided next. Implementation Hints Using Pthreads (Section 4.4.1), begin by creating n students and m tutors 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 help from the tutor. If the tutor is available, they will obtain help. Otherwise, they will either sit in a chair in the waiting area or, if no chairs are available, will resume programming and seek help at a later time When a student arrives and finds an empty chair, the student must notify the coordinator using a semaphore. When the tutor is free (initially and after helping a student), the tutor must notify the coordinator using a semaphore. Also, waiting students and tutors must be woken up by the coordinator using separate semaphores. For details on how to use pthreads synchronization primitives mutex and semaphore see section 5.9.4 of the book. For a detailed tutorial on Pthreads and Semaphores, see https://computing.llnl.gov/tutorials/pthreads/#Thread To simulate students programming in students threads, and the tutor providing help to a student in the tutor thread, the appropriate threads should sleep (by invoking sleepO) for a random of time (up to three seconds) The total number of students, the number of tutors, the number of chairs, and the number of times a student seeks a tutor's help are passed as command line arguments as shown below (csmc is the name of the executable) csmc #students #tutors #chairs #help csmc 10 345 king Tutor Problem The computer science department runs a mentoring center to help undergraduate students with their programming assignments. The lab has a coordinator and several tutors 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 tutors are waiting for students to be assigned by coordinator. A student who arrives at the center seeking help 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 tutor, if there is one, and assigns the student to the tutor. If all the tutors are busy assisting students, the coordinator waits for a tutor to get free and then assigns a waiting student to the tutor. A tutor 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, tutors, and the students. Some hints to implement this project are provided next. Implementation Hints Using Pthreads (Section 4.4.1), begin by creating n students and m tutors 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 help from the tutor. If the tutor is available, they will obtain help. Otherwise, they will either sit in a chair in the waiting area or, if no chairs are available, will resume programming and seek help at a later time When a student arrives and finds an empty chair, the student must notify the coordinator using a semaphore. When the tutor is free (initially and after helping a student), the tutor must notify the coordinator using a semaphore. Also, waiting students and tutors must be woken up by the coordinator using separate semaphores. For details on how to use pthreads synchronization primitives mutex and semaphore see section 5.9.4 of the book. For a detailed tutorial on Pthreads and Semaphores, see https://computing.llnl.gov/tutorials/pthreads/#Thread To simulate students programming in students threads, and the tutor providing help to a student in the tutor thread, the appropriate threads should sleep (by invoking sleepO) for a random of time (up to three seconds) The total number of students, the number of tutors, the number of chairs, and the number of times a student seeks a tutor's help are passed as command line arguments as shown below (csmc is the name of the executable) csmc #students #tutors #chairs #help csmc 10 345Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started