Search code examples
interruptadaprotected

Ada - does pragma Attach_Handler() can attach handler with System.Priority'Last priority?


The next two declarations are equivalent:

protected type prot_Type is
    ....
    pragma Priority(System.Priority'Last);
end;


protected type prot_Type is
    ....
end;

One way of attaching interrupt handler is:

 protected type prot_Type is
     procedure Handler;
     pragma Attach_Handler(Handler, ...);
 end;

 --//Attach is made at the creation of the next object:
 Object : prot_Type;

it's a legal attachment (It works).

How is it possible that the handler has ceiling priority of System.Priority Last ? (As far as I know the legal priority is in range Priority'Last+1 .. Any_Priority'Last).

Another thing: if I add the pragma Priority(System.Priority'Last); to the protected declaration, a program_error exception is raised at the elaboration (when attaching the handler).

Someone can please spread the fog?


Solution

  • I finally manage to understand thanks to: http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node33.htm

    The fact that an hadler that defined in a protected with ceiling priority System.Priority'Last managed to be attached to Interrupt seems to me like bug in the compiler.

    Only hendlers that defined in a protected with ceiling priority in Interrupt_Prioriy'Range can be attached to interrupt.

    Another important thing - for non static protected (i.e declared with "protected type ... ") the attachment is made by the creation of the object of that type. The object must be allocated dynamicly.

    Yony.