Changeset 7e66865e in rtems


Ignore:
Timestamp:
Apr 29, 2016, 9:05:36 AM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6741d30a
Parents:
88e09b98
git-author:
Sebastian Huber <sebastian.huber@…> (04/29/16 09:05:36)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/02/16 05:46:15)
Message:

score: Move message notification

Move message notification to end of critical section and delegate the
message queue release to the notification handler. It may do more
complex notification actions out of the critical section.

Update #2555.

Location:
cpukit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/mqueuenotify.c

    r88e09b98 r7e66865e  
    4040
    4141static void _POSIX_Message_queue_Notify_handler(
    42   void    *user_data
     42  CORE_message_queue_Control *the_message_queue,
     43  ISR_lock_Context           *lock_context
    4344)
    4445{
    4546  POSIX_Message_queue_Control *the_mq;
     47  int                          signo;
    4648
    47   the_mq = user_data;
     49  the_mq = RTEMS_CONTAINER_OF(
     50    the_message_queue,
     51    POSIX_Message_queue_Control,
     52    Message_queue
     53  );
    4854
    49   kill( getpid(), the_mq->notification.sigev_signo );
     55  signo = the_mq->notification.sigev_signo;
     56  _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL );
     57  _CORE_message_queue_Release( &the_mq->Message_queue, lock_context );
    5058
    51   _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
     59  kill( getpid(), signo );
    5260}
    5361
     
    7381        }
    7482
    75         _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
     83        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL );
    7684
    7785        the_mq->notification = *notification;
     
    7987        _CORE_message_queue_Set_notify(
    8088          &the_mq->Message_queue,
    81           _POSIX_Message_queue_Notify_handler,
    82           the_mq
     89          _POSIX_Message_queue_Notify_handler
    8390        );
    8491      } else {
    8592
    86         _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
     93        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL );
    8794
    8895      }
  • cpukit/score/include/rtems/score/coremsg.h

    r88e09b98 r7e66865e  
    2121
    2222#include <rtems/score/chain.h>
     23#include <rtems/score/isrlock.h>
    2324#include <rtems/score/threadq.h>
    2425#include <rtems/score/watchdog.h>
     
    6364  #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND
    6465#endif
     66
     67typedef struct CORE_message_queue_Control CORE_message_queue_Control;
    6568
    6669/**
     
    118121   *  0->1 transition on pending messages.
    119122   */
    120   typedef void (*CORE_message_queue_Notify_Handler)( void * );
     123  typedef void (*CORE_message_queue_Notify_Handler)(
     124    CORE_message_queue_Control *,
     125    ISR_lock_Context *
     126  );
    121127#endif
    122128
     
    127133 *  Message Queue.
    128134 */
    129 typedef struct {
     135struct CORE_message_queue_Control {
    130136  /** This field is the Waiting Queue used to manage the set of tasks
    131137   *  which are blocked waiting to receive a message from this queue.
     
    163169     */
    164170    CORE_message_queue_Notify_Handler  notify_handler;
    165     /** This field is the argument passed to the @ref notify_argument. */
    166     void                              *notify_argument;
    167171  #endif
    168172  /** This chain is the set of inactive messages.  A message is inactive
     
    170174   */
    171175  Chain_Control                      Inactive_messages;
    172 }   CORE_message_queue_Control;
     176};
    173177
    174178/**@}*/
  • cpukit/score/include/rtems/score/coremsgimpl.h

    r88e09b98 r7e66865e  
    613613  RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify (
    614614    CORE_message_queue_Control        *the_message_queue,
    615     CORE_message_queue_Notify_Handler  the_handler,
    616     void                              *the_argument
     615    CORE_message_queue_Notify_Handler  the_handler
    617616  )
    618617  {
    619     the_message_queue->notify_handler  = the_handler;
    620     the_message_queue->notify_argument = the_argument;
     618    the_message_queue->notify_handler = the_handler;
    621619  }
    622620#else
    623621  /* turn it into nothing if not enabled */
    624   #define _CORE_message_queue_Set_notify( \
    625            the_message_queue, the_handler, the_argument )
     622  #define _CORE_message_queue_Set_notify( the_message_queue, the_handler ) \
     623    do { } while ( 0 )
    626624#endif
    627625
  • cpukit/score/src/coremsg.c

    r88e09b98 r7e66865e  
    5656  the_message_queue->number_of_pending_messages = 0;
    5757  the_message_queue->maximum_message_size       = maximum_message_size;
    58   _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
     58  _CORE_message_queue_Set_notify( the_message_queue, NULL );
    5959
    6060  allocated_message_size = maximum_message_size;
  • cpukit/score/src/coremsginsert.c

    r88e09b98 r7e66865e  
    4747{
    4848  Chain_Control *pending_messages;
    49 #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    50   bool           notify;
    51 #endif
    5249
    5350  the_message->Contents.size = content_size;
     
    6461
    6562  pending_messages = &the_message_queue->Pending_messages;
    66 
    67 #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    68   notify = ( the_message_queue->number_of_pending_messages == 0 );
    69 #endif
    7063  ++the_message_queue->number_of_pending_messages;
    7164
     
    8376    _Chain_Prepend_unprotected( pending_messages, &the_message->Node );
    8477  }
    85 
    86   #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
    87     /*
    88      *  According to POSIX, does this happen before or after the message
    89      *  is actually enqueued.  It is logical to think afterwards, because
    90      *  the message is actually in the queue at this point.
    91      */
    92     if ( notify && the_message_queue->notify_handler )
    93       (*the_message_queue->notify_handler)(the_message_queue->notify_argument);
    94   #endif
    9578}
  • cpukit/score/src/coremsgsubmit.c

    r88e09b98 r7e66865e  
    8080      submit_type
    8181    );
     82
     83#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION)
     84    /*
     85     *  According to POSIX, does this happen before or after the message
     86     *  is actually enqueued.  It is logical to think afterwards, because
     87     *  the message is actually in the queue at this point.
     88     */
     89    if (
     90      the_message_queue->number_of_pending_messages == 1
     91        && the_message_queue->notify_handler != NULL
     92    ) {
     93      ( *the_message_queue->notify_handler )(
     94        the_message_queue,
     95        lock_context
     96      );
     97    } else {
     98      _CORE_message_queue_Release( the_message_queue, lock_context );
     99    }
     100#else
    82101    _CORE_message_queue_Release( the_message_queue, lock_context );
     102#endif
     103
    83104    return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
    84105  }
Note: See TracChangeset for help on using the changeset viewer.