Ada 95 Quality and Style Guide | Chapter 6 |
6.3.1 Avoiding Undesired Terminationguideline
Consider using an exception handler for a rendezvous within the main loop inside each task. example
In the following example, an exception raised using the primary sensor is used to change Mode to Degraded still allowing execution of the system:
... loop Recognize_Degraded_Mode: begin case Mode is when Primary => select Current_Position_Primary.Request_New_Coordinates (X, Y); or delay 0.25; -- Decide whether to switch modes; end select; when Degraded => Current_Position_Backup.Request_New_Coordinates (X, Y); end case; ... exception when Tasking_Error | Program_Error => Mode := Degraded; end Recognize_Degraded_Mode; end loop; ...rationale
Allowing a task to terminate might not support the requirements of the system. Without an exception handler for the rendezvous within the main task loop, the functions of the task might not be performed.
notes
The use of an exception handler is the only way to guarantee recovery from an entry call to an abnormal task. Use of the 'Terminated attribute to test a task's availability before making the entry call can introduce a race condition where the tested task fails after the test but before the entry call (see Guideline 6.2.3).
< Previous Page | Search | Contents | Index | Next Page > |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC |
Appendix | References | Bibliography |