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 | #if defined(RTEMS_MULTIPROCESSING) |
---|
33 | #include <rtems/score/mpci.h> |
---|
34 | #endif |
---|
35 | |
---|
36 | /*PAGE |
---|
37 | * |
---|
38 | * _CORE_message_queue_Close |
---|
39 | * |
---|
40 | * This function closes a message by returning all allocated space and |
---|
41 | * flushing the message_queue's task wait queue. |
---|
42 | * |
---|
43 | * Input parameters: |
---|
44 | * the_message_queue - the message_queue to be flushed |
---|
45 | * remote_extract_callout - function to invoke remotely |
---|
46 | * status - status to pass to thread |
---|
47 | * |
---|
48 | * Output parameters: NONE |
---|
49 | */ |
---|
50 | |
---|
51 | void _CORE_message_queue_Close( |
---|
52 | CORE_message_queue_Control *the_message_queue, |
---|
53 | Thread_queue_Flush_callout remote_extract_callout, |
---|
54 | uint32_t status |
---|
55 | ) |
---|
56 | { |
---|
57 | |
---|
58 | /* |
---|
59 | * This will flush blocked threads whether they were blocked on |
---|
60 | * a send or receive. |
---|
61 | */ |
---|
62 | |
---|
63 | _Thread_queue_Flush( |
---|
64 | &the_message_queue->Wait_queue, |
---|
65 | remote_extract_callout, |
---|
66 | status |
---|
67 | ); |
---|
68 | |
---|
69 | /* |
---|
70 | * This removes all messages from the pending message queue. Since |
---|
71 | * we just flushed all waiting threads, we don't have to worry about |
---|
72 | * the flush satisfying any blocked senders as a side-effect. |
---|
73 | */ |
---|
74 | |
---|
75 | if ( the_message_queue->number_of_pending_messages != 0 ) |
---|
76 | (void) _CORE_message_queue_Flush_support( the_message_queue ); |
---|
77 | |
---|
78 | (void) _Workspace_Free( the_message_queue->message_buffers ); |
---|
79 | |
---|
80 | } |
---|