Question 1

A viewing platform has seating space for at most 100 people at any one time. People are only admitted when the platform is open and the number of persons does not exceed the prescribed limit. A person once admitted must find an unoccupied seat. Two persons may not share the same seat.

Using condition variables write a class that could be used to control access to the platform and that manages seat allocation so as to maximize concurrent activity.

By creating multiple threads to represent people accessing the platform write a simulator for your control.

Question 2

Write a class called QueueManager that manages two integer lists. One of its public methods is the function atomicSwap that exchanges two values in the lists. This method takes two index values, one for each list, and exchanges the values. Should either index be out of bounds it should throw an exception. In the event that either list is empty it should also throw the same exception. The swap must appear to occur atomically an external thread should not be able to observe that an item has been removed from one list but not inserted onto the other one. In addition, the implementation must be concurrent it must allow multiple swaps to happen in parallel. Finally, the system should never deadlock. You should write a program to test your solution.

Question 3 Bounded Overtaking Resource Manager

In the ResourceAllocator class described in the lectures client requests are satisfied in first-come-first-served order. In some situations this is not the fairest way to allocate resources because clients with large requests can hold up unnecessarily clients with small requests. One solution is to allow clients with small requests to proceed within certain limits. This is called the bounded overtaking solution because it puts a limit on the number of times clients with large requests may be passed over. Your task is to write a resource manager that sets a limit on the number of times a client may be passed over before receiving their requested resources. Each client has an overtaken count and when this reaches its limit this client must be served next. (See Example 7 in the chapter on Semaphores, Latches and Barriers of your textbook for a discussion of the ResourceAllocator class.)

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.