Question: Write an outline of a multithreading algorithm that simulate the following case: In the cs lab, 1 0 students practice writing programs. Student alternate between
Write an outline of a multithreading algorithm that simulate the following case:
In the cs lab, students practice writing programs.
Student alternate between programming for some time and going for help from the teacher.
When arrived to the teacher, students will get help if he is available. Otherwise, they either sit in the waiting chair or if TA is busy resume programming and will seek help at later time. There are two waiting seats outside the teachers' room.
If there are no waiting students sitting on the chairs, the teacher takes a nap. If one student arrive he will wake up the teacher who then will call one student in for help.
When the teacher finishes helping a student, he must check to see if there are students waiting for help. If so the TA must help each of these students in turn. If no students are present, the teacher may return to napping.
You may simulate students programming as well as the teacher providing help to a student is to have the appropriate threads sleep for a random period of time.
In you answer, identify the critical regions shared resources identify the number of threads, name of threads, role of each thread, semaphores you need to use to synchronize between the threads.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
