using rtems_message_queue_send in interrupt context

Joel Sherrill joel.sherrill at OARcorp.com
Wed Aug 1 12:37:59 UTC 2001



suvrat gupta wrote:
> 
> Hi,
> RTEMS documentation says that its okay to use rtems_message_queue_send in
> interrupt context.
> The file coremsgsubmit.c seem to have a problem:
> ******************
> void _CORE_message_queue_Submit(
>   CORE_message_queue_Control                *the_message_queue,
>   void                                      *buffer,
>   unsigned32                                 size,
>   Objects_Id                                 id,
>   CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
>   CORE_message_queue_Submit_types            submit_type,
>   boolean                                    wait,
>   Watchdog_Interval                          timeout
> )
> {
>   ISR_Level                            level;
>   CORE_message_queue_Buffer_control   *the_message;
>   Thread_Control                      *the_thread;
>   Thread_Control                      *executing;
> 
>   _Thread_Executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
> *********************
> 
> What does _Thread_Executing points to when this function is called form an
> interrupt context?

It (unfortunately) points to the interrupted task.  

> If this point to the task which was interrupted when an interrupt occurred
> then we will update the return value for that task too!
> According to us you cannot use send to message queue function in both task and
> interrupt context at the same time.

This is correct by this bug.

I think this is actually simple to fix.  The routine
_CORE_message_queue_Submit
just needs to return a status rather than set the 
_Thread_Executing->Wait.return_code.  This will propagate to the 
wrapper routine _CORE_message_queue_Send but the usage of both routines
is limited.

FWIW this bug is not in the core semaphore or mutex code.  Given the
code patterns in RTEMS I wanted to check.  

> Am I missing something here? Is this a known problem? Or do I have old
> documentation.I am working on 4.5.0

No.  No.  No.

> thanks
> -suvrat

-- 
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 mailing list