source: rtems/cpukit/rtems/src/taskwakewhen.c @ 812da54

4.104.114.84.95
Last change on this file since 812da54 was 812da54, checked in by Joel Sherrill <joel.sherrill@…>, on 04/02/07 at 18:23:59

2007-04-02 Joel Sherrill <joel@…>

  • itron/src/itrontime.c, libcsupport/src/gettod.c, posix/include/rtems/posix/time.h, posix/include/rtems/posix/timer.h, posix/src/clockgettime.c, posix/src/clocksettime.c, posix/src/nanosleep.c, posix/src/posixtimespecsubtract.c, posix/src/posixtimespectointerval.c, posix/src/ptimer1.c, posix/src/sleep.c, rtems/Makefile.am, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/src/clockget.c, rtems/src/clockset.c, rtems/src/clocktodtoseconds.c, rtems/src/clocktodvalidate.c, rtems/src/taskwakewhen.c, score/Makefile.am, score/include/rtems/score/tod.h, score/inline/rtems/score/tod.inl, score/src/coretod.c, score/src/coretodset.c: Convert from Classic API style TOD_Control as fundamental time structure to POSIX struct timespec. Add clock_get_uptime().
  • rtems/src/clockgetuptime.c, score/src/coretodget.c, score/src/coretodgetuptime.c: New files.
  • score/src/coretodtickle.c, score/src/coretodtoseconds.c, score/src/coretodvalidate.c: Removed.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/rtems/modes.h>
23#include <rtems/rtems/clock.h>
24#include <rtems/score/object.h>
25#include <rtems/score/stack.h>
26#include <rtems/score/states.h>
27#include <rtems/rtems/tasks.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/threadq.h>
30#include <rtems/score/tod.h>
31#include <rtems/score/userext.h>
32#include <rtems/score/wkspace.h>
33#include <rtems/score/apiext.h>
34#include <rtems/score/sysstate.h>
35
36/*PAGE
37 *
38 *  rtems_task_wake_when
39 *
40 *  This directive blocks the requesting thread until the given date and
41 *  time is reached.
42 *
43 *  Input parameters:
44 *    time_buffer - pointer to the time and date structure
45 *
46 *  Output parameters:
47 *    RTEMS_SUCCESSFUL - if successful
48 *    error code       - if unsuccessful
49 */
50
51rtems_status_code rtems_task_wake_when(
52  rtems_time_of_day *time_buffer
53)
54{
55  Watchdog_Interval   seconds;
56
57  if ( !_TOD_Is_set )
58    return RTEMS_NOT_DEFINED;
59
60  if ( !time_buffer )
61    return RTEMS_INVALID_ADDRESS;
62
63  time_buffer->ticks = 0;
64
65  if ( !_TOD_Validate( time_buffer ) )
66    return RTEMS_INVALID_CLOCK;
67
68  seconds = _TOD_To_seconds( time_buffer );
69
70  if ( seconds <= _TOD_Seconds_since_epoch )
71    return RTEMS_INVALID_CLOCK;
72
73  _Thread_Disable_dispatch();
74    _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME );
75    _Watchdog_Initialize(
76      &_Thread_Executing->Timer,
77      _Thread_Delay_ended,
78      _Thread_Executing->Object.id,
79      NULL
80    );
81    _Watchdog_Insert_seconds(
82      &_Thread_Executing->Timer,
83      seconds - _TOD_Seconds_since_epoch
84    );
85  _Thread_Enable_dispatch();
86  return RTEMS_SUCCESSFUL;
87}
Note: See TracBrowser for help on using the repository browser.