Lecture 7 HOMEWORK PROBLEM 6 INTRODUCTION TO Ada I 586.1 PURPOSE: To learn about Ada tasking and how to use it. Do one of the two homework assignments: A plane chasing a target and firing a missile. An elevator system with three elevators. END RESULT: A complete Ada program that is a main procedure that WITH's a package you write containing the tasks. This is the first of a sequence of three assignments that will result in one program. PROBLEM: Plane, target and missile problem: HW6 is to get the target flying. HW7 is to get the chase plane following the target. HW8 is to launch a missile at the target. Tasking will be used for the target,plane and missile . These will be simple tasks like "SHOOT". A rendezvous task will be used to access shared data. ( REPORT and READ_OUT ) A special PLOT task is needed that uses only one PUT to output the cursor position and character. The target is to be started as a task from the main procedure. The main procedure must be kept alive until the task terminates. The elevator problem is at the end of this handout. OBSERVE: All the tasks may be placed in a single package. The main program may be used to clean house at the end of execution. READING: BARNES 14. 1815A 9. NOTES: Different compilers will have different algorithms for context switching while tasking. VAX Ada does minimum context switching as does WADA. TELESOFT seems to stay in a task ( including the main procedure as long as computation is possible. The context switch occurs when any form of PUT is executed. I/O takes a relatively long time, thus if one task has output then all parallel tasks that must be kept running must also have output ( or must be locked from execution some other way ). The main procedure is the sponsor of the SHARED task and thus must be kept running until the TARGET, PLANE, and MISSILE task are complete. The global time T is used to synchronize all tasks and main program termination. Any code can set T to a large number to stop the process. This works reliably because the only other action to change T is to increment it. It would seem reasonable if GET would suspend waiting for input and let parallel task run. It doesn't! The entries SHARED.REPORT and SHARED.READ_OUT are to ensure that the four values X,Y,VX,VY are a consistent set independent of the context switching algorithm. This is the standard Ada construct for shared data.