source: rtems/c/src/exec/itron/src/tsnd_mbf.c @ 3bb9542c

Last change on this file since 3bb9542c was 3bb9542c, checked in by Joel Sherrill <joel.sherrill@…>, on 08/09/01 at 21:08:50

2001-08-09 Joel Sherrill <joel@…>

  • c/src/exec/itron/src/snd_mbx.c, c/src/exec/itron/src/tsnd_mbf.c c/src/exec/posix/src/mqueuesendsupp.c, c/src/exec/rtems/src/msgqsubmit.c, c/src/exec/score/include/rtems/score/coremsg.h, c/src/exec/score/inline/rtems/score/coremsg.inl, c/src/exec/score/src/coremsgsubmit.c: Unblocking message queue operations should NOT use _Thread_Executing for return status since it is permissible to invoke message send operations from an ISR. This was reported by Suvrat Gupta <suvrat@…>.
  • 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  CORE_message_queue_Status      msg_status;
37
38  if (msgsz <= 0 || !msg)
39    return E_PAR;
40
41  interval = 0;
42  if ( tmout == TMO_POL ) {
43    wait = FALSE;
44  } else {
45    wait = TRUE;
46    if ( tmout != TMO_FEVR )
47      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
48  }
49
50  if ( wait && _ITRON_Is_in_non_task_state() )
51    return E_CTX;
52
53  the_message_buffer = _ITRON_Message_buffer_Get(mbfid, &location);
54  switch (location) {
55    case OBJECTS_REMOTE:
56    case OBJECTS_ERROR:           /* Multiprocessing not supported */
57      return _ITRON_Message_buffer_Clarify_get_id_error(mbfid);
58
59    case OBJECTS_LOCAL:
60      /* XXX Submit needs to take into account blocking */
61      msg_status = _CORE_message_queue_Submit(
62        &the_message_buffer->message_queue,
63        msg,
64        msgsz,
65        the_message_buffer->Object.id,
66        NULL,
67        CORE_MESSAGE_QUEUE_SEND_REQUEST,
68        wait,      /* sender may block */
69        interval   /* timeout interval */
70      );
71      _Thread_Enable_dispatch();
72      return _ITRON_Message_buffer_Translate_core_message_buffer_return_code(
73          msg_status
74      );
75    }
76
77    /*
78     *  If multiprocessing were supported, this is where we would announce
79     *  the existence of the semaphore to the rest of the system.
80     */
81
82#if defined(RTEMS_MULTIPROCESSING)
83#endif
84
85    return E_OK;
86}
Note: See TracBrowser for help on using the repository browser.