"同时,在不可屏蔽中断等级上的ISR不应该使用RTEMS系统调用。否则,将会有不可预料的后果。这主要是因为RTMES的系统调用中没有屏蔽外部中
断。 "
对这段话不是很理解...
系统调用屏不屏蔽外部中断对NMI的ISR来说不是一样的吗?为什么不能使用系统调用呢?
以上是我的见解,不知道对不对?请大家指教!
During the execution of directive calls, critical sections of code may
be executed. When these
sections are encountered, RTEMS disables all maskable interrupts
before the execution of
the section and restores them to the previous level upon completion of
the section. RTEMS
has been optimized to insure that interrupts are disabled for a
minimum length of time.
The maximum length of time interrupts are disabled by RTEMS is
processor dependent and
is detailed in the Timing Specification chapter of the Applications
Supplement document
for a specific target processor.
Non-maskable interrupts (NMI) cannot be disabled, and ISRs which
execute at this level
MUST NEVER issue RTEMS system calls. If a directive is invoked,
unpredictable results
may occur due to the inability of RTEMS to protect its critical
sections. However, ISRs
that make no system calls may safely execute as non-maskable
interrupts.
> >> 系统调用屏不屏蔽外部中断对NMI的ISR来说不是一样的吗?为什么不能使用系统调用呢?- 隐藏被引用文字 -
>
> - 显示引用的文字 -
系统调用中只屏蔽普通中断,不屏蔽NMI,这点上面Julyon是正确的,原始文档有问题,我会找机会修正。
这段话的理解上面还是有些需要解释。每个中断源可能有不同的ISR_handler,比如NMI可能有自己的ISR_Handler,并且如果系统中有NMI,
那么NMI肯定是是优先级比较高的ISR。对于普通的中断处理中,可以调用例如sem_post这样的函数。
对于NMI的处理就比较麻烦了,如果在NMI中和普通ISR中都做同一个系统调用例如sem_post时访问系统的链表。那么假设先进入普通ISR,在post的时候来了NMI,又进入了NMI的handler,NMI中继续对互斥资源做操作。那么肯定NMI会破坏普通ISR系统调用中的共享资源。所以NMI的中断处理中不能调用会访问共享资源的系统调用。
--
Thanks & Best Regards!
Ray, Xu
xu ray 写道:
严格来说,这种理解不够准确。RAY最后一句已经说得很明白和准确:NMI的中断处-理中不能调用会访问共享资源的系统调用。
因此"NMI的ISR不能调用系统调用"这句话严格来说应该不够准确。
而Ziyu Yu ,你说得"NMI的ISR只能调用可重入的函数"这说话不够准确,因为NMI的ISR也可以调用可重入的函数啊,只要你保证系统只有
这个ISR调用(或能实现互斥访问)就行,因此跟这个函数是否是可重入没有多大关系。
这其实是一个很简单的临界区问题。RAY也说得很明白了。
也希望大家能多参阅原始的E文文档,因为这么多年以来RTEMS有了不少的变化,我也因为忙于生计,没有同步更新和修改中文问文档的错误。
大家对中文文档中的疑问和错漏之处,还望多提意见。
2009/5/8 julyon <jul...@126.com>:
--