Wednesday, September 12, 2012

AdaTutor - Outside Assignment 6

Exercise in Tasking

On page 33 of your printed course notes is a listing of TASKING.DUM. This program calls a task entry to display Tick! on the screen every five seconds until it has been displayed nine times.

Every time delay is executed, the message (5-second delay) is displayed so that the delay will be visible on the screen.  The program is entirely in lower case, because your assignment is to modify it.  If you make your modifications in upper case, it will be easy to see what you've changed.

We want you to change the declaration of T from a single task to an array of three tasks.  The tasks are numbered 1, 2, and 3.  Task 1 is to be activated every two five-second intervals.  Task 2 is to be activated every three five- -second intervals, and task 3, every four.  Also, instead of displaying Tick!, each task will identify itself by number, for example, Task number 3 is starting.  Output should look as shown on page 35 of your printed notes.

We recommend that you create an array of three counters.  Each counter counts down from its period (2, 3, or 4) to zero by one count every interval.  When a counter reaches zero, the corresponding task entry is called, and the counter is reset to its period.  All three counters should be initialized to zero, so that all three tasks display their messages immediately upon activation of the program.  You should use the rendezvous mechanism to inform each task of its number (1, 2, or 3).  Your program should use a loop to do an orderly shutdown of all three tasks at the end.

Here are the steps to follow for Outside Assignment 6.  They're also in your printed course notes on page 34:

  1. Copy the file TASKING.DUM to TASKING.ADA.  Compile, link, and execute the program to make sure it displays Tick! nine times, with a 5-second delay after each "Tick."
  2. Edit TASKING.ADA to become your solution.  Make your changes in upper case.
  3. Compile TASKING.ADA, link, and execute.
  4. Compare your output with page 35 of your printed course notes.  If there are any errors, go back to step 2.
  5. When your output agrees with your printed course notes, you've finished the assignment and will have a chance to compare your solution with ours.
Please stop reading AdaTutor temporarily, and try Outside Assignment 6.  Work at your own pace; there's no deadline. Good luck!

Congratulations on Completing Outside Assignment 6!

If you like, you can compare your solution with ours, which is in TASKING.ANS.  A listing is on page 36 of your printed course notes.  Your solution might be different from ours, but if your output agrees with page 35 of your printed course notes, your solution is correct.

You've learned a great deal of Ada!  Let's go on to discuss some more records and types.

Click to view our solution:

< prev   next >

Post a Comment