First implement a counting semaphore in Ada using protected types or Java using
ID: 3622553 • Letter: F
Question
First implement a counting semaphore in Ada using protected types or Java using synchronized methods. Implementation using a “protected type” is preferred. Now implement the landing officer of Lab 1 as a “task type” and shuttles as a “task type” (or classes extending thread in Java) accepting their names and other appropriate information via discriminates, constructor, or appropriate initialization protocol.Create a fleet of 10 shuttles and 3 landing officers as arrays of task resources. Each shuttle must take off and land 5 times prior to terminating. Shuttles do not require assistance to takeoff. Again, a landing officer may only work with one shuttle at a time. Each shuttle must use your counting semaphore to gain access to a landing officer. Shuttles and landing officers must clearly identify their selves and client each time they generate output. A race condition results in destruction of the entire fleet. Shuttles and landing officers are subject to the constraints in lab 1.
Successfully complete the mission allowing your pool of shuttles to compete for the attention of 2 landing officers.
You may use Windows, Unix (Linux), or Apple as the OS. If you have another choice, convenience me it is appropriate. Preferred languages include Java, C++ and ADA.
Explanation / Answer
Well, to get you started, here's a counting (e.g. an integer) semaphore implemented in Ada: task body semaphore is val : integer; begin accept Start(default : integer) do val := default end Start; loop if val > 0 then select accept P do val := val - 1; end P; or accept V do val := val + 1; end V; end select; else accept V do val := val + 1; end V; end if; end loop; end semaphore;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.