message_queue_send OK from an ISR, but timer_fire_* aren't?
Joel Sherrill <joel@OARcorp.com>
joel.sherrill at OARcorp.com
Wed Apr 7 12:53:06 UTC 2004
Phil Torre wrote:
> In the C User's Guide on the page which lists those RTEMS functions
> which can be called from an interrupt, I see that message_queue_send
> is OK, but timer_fire_after is not.
> I looked at the code for timer_fire_after and saw the call to
> _Thread_Enable_dispatch(), and thought perhaps that was why this
> function is disallowed. But I then looked at message_queue_send,
> and see that it also calls _Thread_Enable_dispatch().
> 1) Does anyone know offhand why timer_fire_* aren't allowed?
I would say that that list was conservative and based upon
the premise that only unblocking were necessary from an ISR.
No others were reviewed to make that master list.
> 2) TSRs run in the context of the clock tick interrupt, right?
> Based on that assumption, we have application code which sets
> a timer; when the timer fires, the TSR does its thing and
> then sends a message to the foreground, which resets the timer
> for next time. We had to do that, because the TSR isn't allowed
> to call RTEMS timer functions. Right?
If the rule that you shouldn't call timer_fire_after from a TSR
is indeed neccessary, then yes.
> 3) Is the prohibition against calling timer functions from an ISR of
> the "You shouldn't do this, it may be slow" variety, or more the
> "You mustn't do this, it will cause the universe to implode" sort?
I would lean to the more conservative "shouldn't" and not
analyzed for use from a TSR or more general ISR.
I suspect that it is probably OK now but a review
would be necessary to ensure that. If you want to
perform the analysis, I would be willing to include
both fire after and when as allowed from a TSR. Off the
top of my head, the primary cases to consider are:
+ reinsertion of the same timer from its invocation
+ insertion of a different timer from a TSR
+ insertion of a timer from a ISR
Since after and when use the same infrastructure,
analysis of one will apply to the other. Server
scheduler timer routines probably should be analyzed
as well in regards to reinsertion. The issue is that you
are inserting a timer onto a list while you are running
that list. There is a critical section and consistency
FWIW cancel should always be allowed. So hopefully this
is documented as such.
> Thank you!
> P.S. This very question was asked in this message, but I was unable to find
> an on-list reply. Sorry if it's already been answered.
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users