Getting Started with M1750 Ada: Ada 95 Compilation System for Spacecraft Microprocessors | ||
---|---|---|
Prev | Chapter 3. Real-Time Programs | Next |
A protected operation that is attached to an interrupt must be a parameterless protected procedure. This is enforced by the pragma Attach_Handler and by the type Parameterless_Handler from package Ada.Interrupts. For interrupt handlers that have pragma Interrupt_Handler and are not attached to an interrupt is it convenient to allow both parameters and protected functions. The XGC compiler supports this as a legal extension to the Ada language.
In the special case where all the operations on a protected type are interrupt level operations, the XGC compiler will generate run-time system calls that avoid the use of the tasking system. Then only if tasks are required will the tasking system be present. This saves about 6K bytes of memory and reduces the amount of unreachable (and untestable) code.
Example 3-5. Example Interrupt Level Protected Object
with Ada.Interrupts.Names; package body Example_Pack is use Ada.Interrupts.Names; protected UART_Handler is procedure Handler; pragma Attach_Handler (Handler, UART_A_Rx_Tx); -- Must be a parameterless procedure procedure Read (Buf : String; Last : Natural); pragma Interrupt_Handler (Read); -- Runs at interrupt level, may have parameters function Count return Integer; pragma Interrupt_Handler (Count); -- Runs at interrupt level, may be a function end UART_Handler; protected body UART_Handler is ... end UART_Handler; end Example_Pack;