接下来的两个声明是等效的:
protected type prot_Type is
....
pragma Priority(System.Priority'Last);
end;
protected type prot_Type is
....
end;
附加中断处理程序的一种方法是:
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;
这是一个合法的附件(有效)。
处理程序的最高优先级怎么可能是 System.Priority
Last ? (据我所知,合法优先级的范围为 Priority'Last+1 .. Any_Priority'Last)。
另一件事:
如果我将pragma Priority(System.Priority'Last);
添加到 protected 声明中,则在详细说明时(附加处理程序时)会引发program_error异常。
有人可以散开迷雾吗?
最佳答案
我终于明白了,感谢: http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node33.htm
在 protected 具有最高优先级的 System.Priority'Last 中定义的 hadler 设法附加到中断,这一事实在我看来就像编译器中的错误。
只有在 Interrupt_Prioriy'Range 中 protected 且具有最高优先级的处理程序才能附加到中断。
另一件重要的事情 - 对于非静态保护(即用“ protected 类型...”声明),附件是通过创建该类型的对象来创建的。该对象必须动态分配。
约尼。
关于interrupt - Ada - pragma Attach_Handler() 是否可以将处理程序附加到 System.Priority'Last 优先级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4497404/