Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do it on Java. Project: The Sleeping Teaching Assistant A university computer science department has a teaching assistant (TA) who helps undergraduate students with

Please do it on Java.

Project: The Sleeping Teaching Assistant

A university computer science department has a teaching assistant (TA) who helps undergraduate students with their programming assignments during regular office hours. The TAs office is rather small and has room for only one desk with a chair and computer. There are three chairs in the hallway outside the office where students can sit and wait if the TA is currently helping another student. When there are no students who need help during office hours, the TA sits at the desk and takes a nap. If a student arrives during office hours and finds the TA sleeping, the student must awaken the TA to ask for help. If a student arrives and finds the TA currently helping another student, the student sits on one of the chairs in the hallway and waits. If no chairs are available, the student will come back at a later time.

Using threads and semaphores, implement a solution in JAVA that coordinates the activities of the TA and the students.

1) Create n students, each will run as a separate thread.

2) Student threads will alternate between programming for a period of time and seeking help from the TA.

3) If the TA is available, students will obtain help

4) If the TA is not available, students will sit in a chair in the hallway (waitList)

5) If no chairs are available, students will resume programming and seek help at a later time

6) If the TA is sleeping, the student will notify TA with a semaphore

7) Use a semaphore to indicate a student in help mode

8) When a TA finishes helping a student, the TA must check to see if there are students waiting for help in the hallway.

9) The TA must help the students waiting in the hallway in the order that they started waiting.

10) If no students are waiting, then the TA can resume napping.

The best option for simulating students programming as well as the TA providing help to a student is to have appropriate threads sleep for a random period of time.

Make sure your output includes when the semaphores acquire permits and release permits, displays current mode (programming or getting help), and TA is sleeping or helping which student.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

4. Apply the framework to understand challenges in teamwork

Answered: 1 week ago

Question

How to solve maths problems with examples

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago

Question

How could assessment be used in an employee development program?

Answered: 1 week ago