source: rtems/c/src/exec/itron/src/tsnd_mbf.c @ 53fb837a

4.104.114.84.95
Last change on this file since 53fb837a was 53fb837a, checked in by Joel Sherrill <joel.sherrill@…>, on 01/13/00 at 19:25:15

POSIX message queues now include complete functionality including
blocking sends when the queue is full. The SuperCore? was enhanced
to support blocking on send. The existing POSIX API was debugged
and numerous test cases were added to psxmsgq01 by Jennifer Averett.
SuperCore? enhancements and resulting modifications to other APIs
were done by Joel.

There is one significant point of interpretation for the POSIX API.
What happens to threads already blocked on a message queue when the
mode of that same message queue is changed from blocking to non-blocking?
We decided to unblock all waiting tasks with an EAGAIN error just
as if a non-blocking version of the same operation had returned
unsatisfied. This case is not discussed in the POSIX standard and
other implementations may have chosen differently.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  ITRON Message Buffer Manager
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#include <itron.h>
15
16#include <rtems/itron/msgbuffer.h>
17#include <rtems/itron/task.h>
18
19#include <assert.h>  /* only for blocking */
20
21/*
22 *  tsnd_mbf - Send Message to MessageBuffer with Timeout
23 */
24
25ER tsnd_mbf(
26  ID  mbfid,
27  VP  msg,
28  INT msgsz,
29  TMO tmout
30)
31{
32  ITRON_Message_buffer_Control  *the_message_buffer;
33  Objects_Locations              location;
34  Watchdog_Interval              interval;
35  boolean                        wait;
36
37  if (msgsz <= 0 || !msg)
38    return E_PAR;
39
40  interval = 0;
41  if ( tmout == TMO_POL ) {
42    wait = FALSE;
43  } else {
44    wait = TRUE;
45    if ( tmout != TMO_FEVR )
46      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
47  }
48
49  if ( wait && _ITRON_Is_in_non_task_state() )
50    return E_CTX;
51
52  the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);
53  switch (location) {
54    case OBJECTS_REMOTE:
55    case OBJECTS_ERROR:           /* Multiprocessing not supported */
56      return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);
57
58    case OBJECTS_LOCAL:
59      /* XXX Submit needs to take into account blocking */
60      _CORE_message_queue_Submit(
61        &the_message_buffer->message_queue,
62        msg,
63        msgsz,
64        the_message_buffer->Object.id,
65        NULL,
66        CORE_MESSAGE_QUEUE_SEND_REQUEST,
67        wait,      /* sender may block */
68        interval   /* timeout interval */
69      );
70      _Thread_Enable_dispatch();
71      return _ITRON_Message_buffer_Translate_core_message_buffer_return_code(
72          _Thread_Executing->Wait.return_code
73      );
74    }
75
76    /*
77     *  If multiprocessing were supported, this is where we would announce
78     *  the existence of the semaphore to the rest of the system.
79     */
80
81#if defined(RTEMS_MULTIPROCESSING)
82#endif
83
84    return E_OK;
85}
Note: See TracBrowser for help on using the repository browser.