source: rtems/cpukit/score/src/coremsg.c @ 82cb78d8

4.104.114.84.95
Last change on this file since 82cb78d8 was 82cb78d8, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 21:45:15

Split core message queue and watchdog handler objects into separate files.

  • Property mode set to 100644
File size: 3.5 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-1998.
11 *  On-Line Applications Research Corporation (OAR).
12 *  Copyright assigned to U.S. Government, 1994.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.OARcorp.com/rtems/license.html.
17 *
18 *  $Id$
19 */
20
21#include <rtems/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/object.h>
25#include <rtems/score/coremsg.h>
26#include <rtems/score/states.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#if defined(RTEMS_MULTIPROCESSING)
30#include <rtems/score/mpci.h>
31#endif
32
33/*PAGE
34 *
35 *  _CORE_message_queue_Initialize
36 *
37 *  This routine initializes a newly created message queue based on the
38 *  specified data.
39 *
40 *  Input parameters:
41 *    the_message_queue            - the message queue to initialize
42 *    the_class                    - the API specific object class
43 *    the_message_queue_attributes - the message queue's attributes
44 *    maximum_pending_messages     - maximum message and reserved buffer count
45 *    maximum_message_size         - maximum size of each message
46 *    proxy_extract_callout        - remote extract support
47 *
48 *  Output parameters:
49 *    TRUE   - if the message queue is initialized
50 *    FALSE  - if the message queue is NOT initialized
51 */
52
53boolean _CORE_message_queue_Initialize(
54  CORE_message_queue_Control    *the_message_queue,
55  Objects_Classes                the_class,
56  CORE_message_queue_Attributes *the_message_queue_attributes,
57  unsigned32                     maximum_pending_messages,
58  unsigned32                     maximum_message_size,
59  Thread_queue_Extract_callout   proxy_extract_callout
60)
61{
62  unsigned32 message_buffering_required;
63  unsigned32 allocated_message_size;
64
65  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
66  the_message_queue->number_of_pending_messages = 0;
67  the_message_queue->maximum_message_size       = maximum_message_size;
68  _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
69 
70  /*
71   * round size up to multiple of a ptr for chain init
72   */
73 
74  allocated_message_size = maximum_message_size;
75  if (allocated_message_size & (sizeof(unsigned32) - 1)) {
76      allocated_message_size += sizeof(unsigned32);
77      allocated_message_size &= ~(sizeof(unsigned32) - 1);
78  }
79   
80  message_buffering_required = maximum_pending_messages *
81       (allocated_message_size + sizeof(CORE_message_queue_Buffer_control));
82 
83  the_message_queue->message_buffers = (CORE_message_queue_Buffer *)
84     _Workspace_Allocate( message_buffering_required );
85 
86  if (the_message_queue->message_buffers == 0)
87    return FALSE;
88 
89  _Chain_Initialize (
90    &the_message_queue->Inactive_messages,
91    the_message_queue->message_buffers,
92    maximum_pending_messages,
93    allocated_message_size + sizeof( CORE_message_queue_Buffer_control )
94  );
95 
96  _Chain_Initialize_empty( &the_message_queue->Pending_messages );
97 
98  _Thread_queue_Initialize(
99    &the_message_queue->Wait_queue,
100    the_class,
101    _CORE_message_queue_Is_priority( the_message_queue_attributes ) ?
102       THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
103    STATES_WAITING_FOR_MESSAGE,
104    proxy_extract_callout,
105    CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
106  );
107
108  return TRUE;
109}
Note: See TracBrowser for help on using the repository browser.