source: rtems/cpukit/posix/include/rtems/posix/mqueue.h @ d17c114

Last change on this file since d17c114 was d17c114, checked in by Joel Sherrill <joel.sherrill@…>, on 07/24/08 at 20:43:24

2008-07-24 Joel Sherrill <joel.sherrill@…>

PR 1291/cpukit

  • posix/src/posixtimespecabsolutetimeout.c: New file.
  • itron/inline/rtems/itron/semaphore.inl, itron/src/twai_sem.c, posix/Makefile.am, posix/include/mqueue.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/semaphore.h, posix/include/rtems/posix/time.h, posix/src/condtimedwait.c, posix/src/mqueuereceive.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesend.c, posix/src/mqueuesendsupp.c, posix/src/mqueuetimedreceive.c, posix/src/mqueuetimedsend.c, posix/src/mutexfromcorestatus.c, posix/src/mutextimedlock.c, posix/src/semaphorewaitsupp.c, posix/src/semtimedwait.c, posix/src/semtrywait.c, posix/src/semwait.c, rtems/src/semobtain.c, rtems/src/semtranslatereturncode.c, score/include/rtems/score/coresem.h, score/src/coremsgseize.c, score/src/coresemseize.c: This patch addresses issues on implementation of the timeout on the following POSIX services. Some of these services incorrectly took a timeout as a relative time. Others would compute a 0 delta to timeout if the absolute time and the current time were equal and thus incorrectly block the caller forever. The root of the confusion is that POSIX specifies that if the timeout is incorrect (e.g. in the past, is now, or is numerically invalid), that it does not matter if the call would succeed without blocking. This is in contrast to RTEMS programming style where all errors are checked before any critical sections are entered. This fix implemented a more uniform way of handling POSIX absolute time timeouts.

+ pthread_cond_timedwait - could block forever
+ mq_timedreceive - used relative not absolute time
+ mq_timedsend - used relative not absolute time
+ pthread_mutex_timedlock - used relative not absolute time
+ pthread_rwlock_timedrdlock- used relative not absolute time
+ pthread_rwlock_timedwrlock- used relative not absolute time
+ sem_timedwait - could block forever

  • Property mode set to 100644
File size: 5.6 KB
Line 
1/**
2 * @file rtems/posix/mqueue.h
3 *
4 *  This include file contains all the private support information for
5 *  POSIX Message Queues.
6 */
7 
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_POSIX_MQUEUE_H
20#define _RTEMS_POSIX_MQUEUE_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <signal.h>
27
28#include <rtems/score/coremsg.h>
29#include <rtems/score/object.h>
30
31/*
32 *  Data Structure used to manage a POSIX message queue
33 */
34
35typedef struct {
36   Objects_Control             Object;
37   int                         process_shared;
38   boolean                     named;
39   boolean                     linked;
40   uint32_t                    open_count;
41   CORE_message_queue_Control  Message_queue;
42   struct sigevent             notification;
43}  POSIX_Message_queue_Control;
44
45typedef struct {
46   Objects_Control              Object;
47   POSIX_Message_queue_Control *Queue;
48   int                          oflag;
49} POSIX_Message_queue_Control_fd;
50
51/*
52 *  The following defines the information control block used to manage
53 *  this class of objects.  The second item is used to manage the set
54 *  of "file descriptors" associated with the message queues.
55 */
56
57POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information;
58POSIX_EXTERN Objects_Information  _POSIX_Message_queue_Information_fds;
59
60/*
61 *  _POSIX_Message_queue_Manager_initialization
62 *
63 *  DESCRIPTION:
64 *
65 *  This routine performs the initialization necessary for this manager.
66 */
67
68void _POSIX_Message_queue_Manager_initialization(
69  uint32_t   maximum_message_queues
70);
71
72/*
73 *
74 *  _POSIX_Message_queue_Create_support
75 *
76 *  DESCRIPTION:
77 *
78 *  This routine performs the creation of a message queue utilizing the
79 *  core message queue.
80 */
81
82int _POSIX_Message_queue_Create_support(
83  const char                    *name,
84  int                            pshared,
85  struct mq_attr                *attr,
86  POSIX_Message_queue_Control  **message_queue
87);
88
89/*
90 *  _POSIX_Message_queue_Delete
91 *
92 *  DESCRIPTION:
93 *
94 *  This routine supports the mq_unlink and mq_close routines by
95 *  doing most of the work involved with removing a message queue.
96 */
97
98void _POSIX_Message_queue_Delete(
99  POSIX_Message_queue_Control *the_mq
100);
101
102/*
103 *  _POSIX_Message_queue_Receive_support
104 *
105 *  DESCRIPTION:
106 *
107 *  This routine supports the various flavors of receiving a message.
108 */
109
110ssize_t _POSIX_Message_queue_Receive_support(
111  mqd_t               mqdes,
112  char               *msg_ptr,
113  size_t              msg_len,
114  unsigned int       *msg_prio,
115  boolean             wait,
116  Watchdog_Interval   timeout
117);
118
119/*
120 *  _POSIX_Message_queue_Send_support
121 *
122 *  DESCRIPTION:
123 *
124 *  This routine posts a message to a specified message queue.
125 */
126
127int _POSIX_Message_queue_Send_support(
128  mqd_t               mqdes,
129  const char         *msg_ptr,
130  size_t              msg_len,
131  uint32_t            msg_prio,
132  boolean             wait,
133  Watchdog_Interval   timeout
134);
135
136/*
137 *  _POSIX_Message_queue_Allocate
138 *
139 *  DESCRIPTION:
140 *
141 *  This function allocates a message queue control block from
142 *  the inactive chain of free message queue control blocks.
143 */
144
145RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void );
146
147/*
148 *  _POSIX_Message_queue_Free
149 *
150 *  DESCRIPTION:
151 *
152 *  This routine frees a message queue control block to the
153 *  inactive chain of free message queue control blocks.
154 */
155
156RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free (
157  POSIX_Message_queue_Control *the_mq
158);
159
160/*
161 *  _POSIX_Message_queue_Get
162 *
163 *  DESCRIPTION:
164 *
165 *  This function maps message queue IDs to message queue control blocks.
166 *  If ID corresponds to a local message queue, then it returns
167 *  the_mq control pointer which maps to ID and location
168 *  is set to OBJECTS_LOCAL.  if the message queue ID is global and
169 *  resides on a remote node, then location is set to OBJECTS_REMOTE,
170 *  and the_message queue is undefined.  Otherwise, location is set
171 *  to OBJECTS_ERROR and the_mq is undefined.
172 */
173
174RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get (
175  Objects_Id         id,
176  Objects_Locations *location
177);
178
179/*
180 *  _POSIX_Message_queue_Is_null
181 *
182 *  DESCRIPTION:
183 *
184 *  This function returns TRUE if the_message_queue is NULL and FALSE otherwise.
185 */
186
187RTEMS_INLINE_ROUTINE boolean _POSIX_Message_queue_Is_null (
188  POSIX_Message_queue_Control *the_mq
189);
190
191/*
192 *  _POSIX_Message_queue_Name_to_id
193 *
194 *  DESCRIPTION:
195 *
196 *  This routine looks up the specified name for a message queue and returns the
197 *  id of the message queue associated with it.
198 */
199
200int _POSIX_Message_queue_Name_to_id(
201  const char          *name,
202  Objects_Id          *id
203);
204
205/*
206 *  _POSIX_Message_queue_Priority_to_core
207 *
208 *  DESCRIPTION:
209 *
210 *  XXX
211 */
212
213RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types _POSIX_Message_queue_Priority_to_core(
214  unsigned int priority
215);
216
217/*
218 *  _POSIX_Message_queue_Priority_from_core
219 *
220 *  DESCRIPTION:
221 *
222 *  XXX
223 */
224
225RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core(
226  CORE_message_queue_Submit_types priority
227);
228
229/*PAGE
230 *
231 *  _POSIX_Message_queue_Translate_core_message_queue_return_code
232 *
233 *  DESCRIPTION:
234 *
235 *  XXX
236 */
237
238int _POSIX_Message_queue_Translate_core_message_queue_return_code(
239  uint32_t   the_message_queue_status
240);
241
242
243#include <rtems/posix/mqueue.inl>
244#if defined(RTEMS_MULTIPROCESSING)
245#include <rtems/posix/mqueuemp.h>
246#endif
247
248#ifdef __cplusplus
249}
250#endif
251
252#endif
253/*  end of include file */
Note: See TracBrowser for help on using the repository browser.