source: rtems/cpukit/score/src/coremsgflushsupp.c @ da42259

4.104.115
Last change on this file since da42259 was b3836ce, checked in by Joel Sherrill <joel.sherrill@…>, on 09/05/08 at 21:54:20

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgflushwait.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/corerwlock.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coresemseize.c, score/src/coresemsurrender.c, score/src/corespinlock.c, score/src/threadblockingoperationcancel.c, score/src/threadqenqueue.c: Remove unnecessary include of mpci.h.
  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  CORE Message Queue Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the CORE Message Queue Handler.
7 *  This core object provides task synchronization and communication functions
8 *  via messages passed to queue objects.
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/system.h>
25#include <rtems/score/chain.h>
26#include <rtems/score/isr.h>
27#include <rtems/score/object.h>
28#include <rtems/score/coremsg.h>
29#include <rtems/score/states.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/wkspace.h>
32
33/*PAGE
34 *
35 *  _CORE_message_queue_Flush_support
36 *
37 *  This message handler routine removes all messages from a message queue
38 *  and returns them to the inactive message pool.  The number of messages
39 *  flushed from the queue is returned
40 *
41 *  Input parameters:
42 *    the_message_queue - pointer to message queue
43 *
44 *  Output parameters:
45 *    returns - number of messages placed on inactive chain
46 *
47 *  INTERRUPT LATENCY:
48 *    only case
49 */
50
51uint32_t   _CORE_message_queue_Flush_support(
52  CORE_message_queue_Control *the_message_queue
53)
54{
55  ISR_Level   level;
56  Chain_Node *inactive_first;
57  Chain_Node *message_queue_first;
58  Chain_Node *message_queue_last;
59  uint32_t    count;
60
61  /*
62   *  Currently, RTEMS supports no API that has both flush and blocking
63   *  sends.  Thus, this routine assumes that there are no senders
64   *  blocked waiting to send messages.  In the event, that an API is
65   *  added that can flush a message queue when threads are blocked
66   *  waiting to send, there are two basic behaviors envisioned:
67   *
68   *  (1) The thread queue of pending senders is a logical extension
69   *  of the pending message queue.  In this case, it should be
70   *  flushed using the _Thread_queue_Flush() service with a status
71   *  such as CORE_MESSAGE_QUEUE_SENDER_FLUSHED (which currently does
72   *  not exist).  This can be implemented without changing the "big-O"
73   *  of the message flushing part of the routine.
74   *
75   *  (2) Only the actual messages queued should be purged.  In this case,
76   *  the blocked sender threads must be allowed to send their messages.
77   *  In this case, the implementation will be forced to individually
78   *  dequeue the senders and queue their messages.  This will force
79   *  this routine to have "big O(n)" where n is the number of blocked
80   *  senders.  If there are more messages pending than senders blocked,
81   *  then the existing flush code can be used to dispose of the remaining
82   *  pending messages.
83   *
84   *  For now, though, we are very happy to have a small routine with
85   *  fixed execution time that only deals with pending messages.
86   */
87
88  _ISR_Disable( level );
89    inactive_first      = the_message_queue->Inactive_messages.first;
90    message_queue_first = the_message_queue->Pending_messages.first;
91    message_queue_last  = the_message_queue->Pending_messages.last;
92
93    the_message_queue->Inactive_messages.first = message_queue_first;
94    message_queue_last->next = inactive_first;
95    inactive_first->previous = message_queue_last;
96    message_queue_first->previous          =
97               _Chain_Head( &the_message_queue->Inactive_messages );
98
99    _Chain_Initialize_empty( &the_message_queue->Pending_messages );
100
101    count = the_message_queue->number_of_pending_messages;
102    the_message_queue->number_of_pending_messages = 0;
103  _ISR_Enable( level );
104  return count;
105}
Note: See TracBrowser for help on using the repository browser.