source: rtems/cpukit/itron/src/cre_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/*
20 *  cre_mbf - Create MessageBuffer
21 */
22
23ER cre_mbf(
24  ID      mbfid,
25  T_CMBF *pk_cmbf
26)
27{
28  CORE_message_queue_Attributes    the_msgq_attributes;
29  ITRON_Message_buffer_Control    *the_message_buffer;
30
31  /*
32   *  Bad pointer to the attributes structure
33   */
34
35  if ( !pk_cmbf )
36    return E_PAR;
37
38  /*
39   *  Bits were set that were note defined.
40   */
41
42  if (pk_cmbf->mbfatr & ~(TA_TPRI))
43    return E_RSATR;
44
45  if (pk_cmbf->bufsz < 0 || pk_cmbf->maxmsz < 0)
46    return E_PAR;
47   
48  if (pk_cmbf->bufsz < pk_cmbf->maxmsz)
49    return E_PAR;
50
51  _Thread_Disable_dispatch();             /* prevents deletion */
52
53  the_message_buffer = _ITRON_Message_buffer_Allocate(mbfid);
54  if ( !the_message_buffer ) {
55    _Thread_Enable_dispatch();
56    return _ITRON_Message_buffer_Clarify_allocation_id_error(mbfid);
57  }
58
59  if ( pk_cmbf->mbfatr & TA_TPRI )
60    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY;
61  else
62    the_msgq_attributes.discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
63
64  _CORE_message_queue_Initialize(
65    &the_message_buffer->message_queue,
66    OBJECTS_ITRON_MESSAGE_BUFFERS,
67    &the_msgq_attributes,
68    pk_cmbf->bufsz / pk_cmbf->maxmsz,
69    pk_cmbf->maxmsz,
70    NULL                           /* Multiprocessing not supported */
71  );
72
73  _ITRON_Objects_Open( &_ITRON_Message_buffer_Information,
74                       &the_message_buffer->Object );
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  _Thread_Enable_dispatch();
85
86  return E_OK;
87}
Note: See TracBrowser for help on using the repository browser.