source: rtems/cpukit/posix/src/condtimedwait.c @ f4c59d0

5
Last change on this file since f4c59d0 was 21789a21, checked in by Sebastian Huber <sebastian.huber@…>, on 07/28/15 at 12:45:42

score: Rename _POSIX_Absolute_timeout_to_ticks()

Rename _POSIX_Absolute_timeout_to_ticks() to
_TOD_Absolute_timeout_to_ticks() and move it to the score directory.
Delete empty <rtems/posix/time.h>.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Waiting on a Condition
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <pthread.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/score/todimpl.h>
26#include <rtems/posix/condimpl.h>
27#include <rtems/posix/muteximpl.h>
28
29/*
30 *  11.4.4 Waiting on a Condition, P1003.1c/Draft 10, p. 105
31 */
32
33int pthread_cond_timedwait(
34  pthread_cond_t        *cond,
35  pthread_mutex_t       *mutex,
36  const struct timespec *abstime
37)
38{
39  Watchdog_Interval                            ticks;
40  bool                                         already_timedout;
41  TOD_Absolute_timeout_conversion_results  status;
42
43  /*
44   *  POSIX requires that blocking calls with timeouts that take
45   *  an absolute timeout must ignore issues with the absolute
46   *  time provided if the operation would otherwise succeed.
47   *  So we check the abstime provided, and hold on to whether it
48   *  is valid or not.  If it isn't correct and in the future,
49   *  then we do a polling operation and convert the UNSATISFIED
50   *  status into the appropriate error.
51   */
52  already_timedout = false;
53  status = _TOD_Absolute_timeout_to_ticks(abstime, &ticks);
54  if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID )
55    return EINVAL;
56
57  if ( status == TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST ||
58       status == TOD_ABSOLUTE_TIMEOUT_IS_NOW )
59    already_timedout = true;
60
61  return _POSIX_Condition_variables_Wait_support(
62    cond,
63    mutex,
64    ticks,
65    already_timedout
66  );
67}
Note: See TracBrowser for help on using the repository browser.