Ada - pragma Attach_Handler() 是否可以使用 System.Priority'Last 优先级附加处理程序?

发布于 2024-10-08 06:36:17 字数 668 浏览 6 评论 0原文

接下来的两个声明是等效的:

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); 添加到受保护的声明中,则在详细说明时(附加处理程序时)会引发 program_error 异常。

有人可以散散迷雾吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

把人绕傻吧 2024-10-15 06:36:17

我终于明白了,感谢:
http://www.iuma.ulpgc.es/users/jmiranda /gnat-rts/node33.htm

在受最高优先级 System.Priority'Last 保护的受保护中定义的 hadler 成功附加到中断的事实在我看来就像编译器中的错误。

只有在 Interrupt_Prioriy'Range 中受保护的最高优先级中定义的处理程序才能附加到中断。

另一个重要的事情 - 对于非静态保护(即用“受保护类型...”声明),附件是通过创建该类型的对象来进行的。该对象必须动态分配。

约尼.

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.

标点 2024-10-15 06:36:17

这个问题是关于将中断(或信号)附加到受保护对象以充当中断处理程序。 Ada 为您提供了一种主要是语言标准的方法来做到这一点,这真是太好了,但是标准中的内容有限制,我认为您的问题击中了一个。您确实需要阅读编译器的文档。

例如,如果您要附加的是一个诚实的系统中断,那么您的处理程序很可能会直接从系统中断中调用,这当然完全在您的两个中断之外(因此高于) OS的进程优先级和Ada的任务优先级系统。

一般来说,在这种情况下,就像任何 ISR 一样,您需要做最少的事情来记录和处理中断,尽可能少地与系统交互(没有 I/O 或任务交互),并且将控制权返回给系统,以便它可以再次开始正常运行。在您的情况下,您可能需要增加一个变量或在标记类型内部设置一个标志,记下有关稍后可能需要的中断的任何易失性信息,然后返回。

This question is about attaching interrupts (or signals) to a protected object to function as interrupt handlers. It is wonderful that Ada provides you a mostly language-standard way to do this, but there are limits to what is in the standard, and I think your question hits one. You really need to read your compiler's documenation for this one.

For example, if what you are attaching to is an honest-to-god system interrupt, then it is quite possible that your handler will get called directly from the system interrupt, which is of course completely outside of (and thus above) both your OS's process priority and Ada's task priority systems.

Generally in such a case, like with any ISR, you'd want to do the absolute minimum required to make note of and deal with the interrupt, interact with the system as little as possible (no I/O or tasking interactions), and return control back to the system so it can start behaving normally again. In your case, you might want to increment a variable or set a flag internal to your tagged type, take down any volatile info about the interrupt you may need later, then return.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文