Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

course :operating system 3. Assume we were to get a teaching assistant for this

ID: 3589878 • Letter: C

Question

course :operating system

3. Assume we were to get a teaching assistant for this course that would hold office hours in B 240. He would sit at one of the cubicles and could only help one student in the class at a time. However, assume there are four chairs in the room that students can sit in to wait for the TA to be available to help them. When nobody is around the TA plays video games. If a student shows up and the TA is playing games, he should stop and help the student. If a student arrives, but the TA is busy, the student will sit down in an empty chair if one exists. When the current student is finished, the student who has waited the longest will be helped next. If there is not an empty chair available, the student will go away and come back later.

a) Write a pseudocode algorithm using semaphores/counters/etc. for both the student and the TA to describe their actions so that everybody gets the help they need.

b) Now assume that we get a second TA for the course and he can also help students in the same room. A waiting student can be helped equally well by either TA. Show how the algorithms for the students and TAs would need to be adjusted to handle this situation.

c) Now assume that the second TA must help students for a different course, but still in the same room with a common set of chairs for students to wait in. So, even if there are students waiting in the room for help, if they are not in the course that a TA is helping with, that TA is free to play video games. Show how the algorithms for a student and a TA would need to be adjusted to handle this situation.

Explanation / Answer

A) if TA == Busy then

        if chair available then

           occpy the chair

            decrease the count of remaining chair

       else

             come back later

else

    if waiting time is highest

       Ask TA for help

   else

      wait for your turn

TA :----

if student available

    Help Student

else

    Play Game

B)

if TA1 == Busy and TA2 == Busy then

        if chair available then

           occpy the chair

            decrease the count of remaining chair

       else

             if TA1 is available and TA2 is busy or TA2 is available and TA1 is busy

                  Student with maximum wait get help

             else

           come back later

else

    if waiting time is highest

       Ask TA for help

   else

      wait for your turn

TA :----

if student available

    Help Student

else

    Play Game

C)

if TA of course available

   Ask the TA for help

else

       if chair available then

           occpy the chair

            decrease the count of remaining chair

       else

             come back later