Computers and Technology

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!

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:20, owoeli
Which of these is a benefit of social networking? oa. hiding your true identity from friendsob. avoiding talking to people in personoc. spending time with friends instead of studyingod. connecting with new people
Answers: 2
image
Computers and Technology, 22.06.2019 12:00, dani19cano
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, jabezslade22
What is the first view you place in your drawing?
Answers: 1
image
Computers and Technology, 22.06.2019 23:00, brooklynmikestovgphx
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
Do you know the correct answer?
The computer science department runs a mentoring center to undergraduate students with their progra...

Questions in other subjects:

Konu
Mathematics, 12.12.2020 17:00
Konu
History, 12.12.2020 17:00
Konu
Mathematics, 12.12.2020 17:00