source: rtems/c/src/exec/score/src/coremsgseize.c @ 58243b4

4.104.114.84.95
Last change on this file since 58243b4 was 58243b4, checked in by Jennifer Averett <Jennifer.Averett@…>, on 01/05/00 at 17:18:08

+ Added return of the message priority.

  • Property mode set to 100644
File size: 3.2 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.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#include <rtems/system.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/coremsg.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#if defined(RTEMS_MULTIPROCESSING)
29#include <rtems/score/mpci.h>
30#endif
31
32/*PAGE
33 *
34 *  _CORE_message_queue_Seize
35 *
36 *  This kernel routine dequeues a message, copies the message buffer to
37 *  a given destination buffer, and frees the message buffer to the
38 *  inactive message pool.  The thread will be blocked if wait is TRUE,
39 *  otherwise an error will be given to the thread if no messages are available.
40 *
41 *  Input parameters:
42 *    the_message_queue - pointer to message queue
43 *    id                - id of object we are waitig on
44 *    buffer            - pointer to message buffer to be filled
45 *    size              - pointer to the size of buffer to be filled
46 *    wait              - TRUE if wait is allowed, FALSE otherwise
47 *    timeout           - time to wait for a message
48 *
49 *  Output parameters:  NONE
50 *
51 *  NOTE: Dependent on BUFFER_LENGTH
52 *
53 *  INTERRUPT LATENCY:
54 *    available
55 *    wait
56 */
57
58void _CORE_message_queue_Seize(
59  CORE_message_queue_Control      *the_message_queue,
60  Objects_Id                       id,
61  void                            *buffer,
62  unsigned32                      *size,
63  boolean                          wait,
64  CORE_message_queue_Submit_types *priority,
65  Watchdog_Interval                timeout
66)
67{
68  ISR_Level                          level;
69  CORE_message_queue_Buffer_control *the_message;
70  Thread_Control                    *executing;
71
72  executing = _Thread_Executing;
73  executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
74  _ISR_Disable( level );
75  if ( the_message_queue->number_of_pending_messages != 0 ) {
76    the_message_queue->number_of_pending_messages -= 1;
77
78    the_message = _CORE_message_queue_Get_pending_message( the_message_queue );
79    _ISR_Enable( level );
80    *size = the_message->Contents.size;
81    *priority = the_message->priority;
82    _CORE_message_queue_Copy_buffer(the_message->Contents.buffer,buffer,*size );
83    _CORE_message_queue_Free_message_buffer(the_message_queue, the_message );
84    return;
85  }
86
87  if ( !wait ) {
88    _ISR_Enable( level );
89    executing->Wait.return_code = CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT;
90    return;
91  }
92
93  _Thread_queue_Enter_critical_section( &the_message_queue->Wait_queue );
94  executing->Wait.queue              = &the_message_queue->Wait_queue;
95  executing->Wait.id                 = id;
96  executing->Wait.return_argument    = (void *)buffer;
97  executing->Wait.return_argument_1  = (void *)size;
98  _ISR_Enable( level );
99
100  _Thread_queue_Enqueue( &the_message_queue->Wait_queue, timeout );
101}
102
Note: See TracBrowser for help on using the repository browser.