a question about _Thread_Dispatch_disable

Joel Sherrill joel.sherrill at oarcorp.com
Tue May 29 14:17:18 UTC 2007


yanmiaobest wrote:
> Hi all,
> I am studying RTEMS supercore code. A question comes up.
> If variables that shared among threads should be protected by 
> _Thread_Disale_dispatch()/_Thread_Enable_dispatch()?
> but when executing those two functions, there is no instructions to 
> disable interrupt, what if an interrupt occures in those functions and 
> modifies the _Thread_Dispatch_disable_level ?
> When to use _ISR_Disable and when to use _Thread_Dispatch_disable ?
First, it is volatile.

Second, it will be increased when you enter the ISR and
decreased when the ISR returns. No matter what value it
had before an ISR occurs, it will have the same value when
the thread executes again.

If it is zero, you are not in a dispatching critical section
and you will eventually return to the same instruction.

If it is non-zero, then the ISR will not result in a preempt
and you will return right to that instruction from the ISR.

Only a restricted set of operations may be performed from
an ISR. In general, no potentially blocking operation or operation
implicitly operating on the current thread should be performed.
So you almost always use Thread Dispatch critical sections and
only use ISR critical sections when you are protecting data
structures which can be modified from an ISR.

Easy to say but harder to recognize until you realize what it
allowed from an ISR.

--joel
>
>
> ------------------------------------------------------------------------
> ÃλÃÎ÷ÓΣ¬Ç§ÍòÈ˵ÄÑ¡Ôñ£¬ÄãµÄÑ¡Ôñ 
> <http://event.mail.163.com/chanel/xyq.htm?from=163_NO2>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list