subject

Must be done in c
seeking ta problem
the computer science department runs a mentoring center to undergraduate students with their programming assignments.
the lab has a coordinator and several tas to assist the students. the waiting area of the center has several chairs. initially, all the chairs are empty.
the coordinator is waiting for the students to arrive and all the tas 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 taing. 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 ta, if there is one, and assigns the student to the ta. if all the tas are busy assisting students, the coordinator waits for a ta to be free and then
assigns a waiting student to the ta. a ta 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, tas, and the students. some hints to implement this project are provided next.
implementation hints
using pthreads, begin by creating n students and m tas 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 ta. if the ta 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 ta is free (initially and after a student)
, the ta must notify the coordinator using a semaphore. also, waiting students and tas must be woken up by the coordinator using separate semaphores. for details on
how to use pthreads, synchronization primitives mutex and semaphores see the book.
to simulate programming and getting in students threads, and the ta providing to a student in the ta 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 tas, the number of chairs, and the number of times a student seeks a ta’s are passed as command line arguments
as shown below (csmc is then ame of the executable):
csmc #students#tas#chairs#
csmc 10 3 4 5
once a student thread takes the required number of from the tas, it should terminate. once all the student threads are terminated, the ta 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
ta [#] student for [#] seconds.
waiting students = [# of students waiting]

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:30, morganwendel126
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. centurion: a commander in the army of ancient rome. keyword: picture:
Answers: 2
image
Computers and Technology, 23.06.2019 04:10, cvbnkifdfg
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
image
Computers and Technology, 23.06.2019 07:00, Dvrsug8598
You need a quick answer from a coworker. the most effective way to reach your coworker is through a. cloud server b. instant message c. teleconference d. telepresence
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, clevelandjaniya1
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
You know the right answer?
Must be done in c
seeking ta problem
the computer science department runs a mentoring...

Questions in other subjects:

Konu
History, 19.11.2020 23:10
Konu
Mathematics, 19.11.2020 23:10
Konu
Mathematics, 19.11.2020 23:10