source: rtems/cpukit/rtems/src/taskwakewhen.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 1.9 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/score/object.h>
24#include <rtems/score/stack.h>
25#include <rtems/score/states.h>
26#include <rtems/rtems/tasks.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/threadq.h>
29#include <rtems/score/tod.h>
30#include <rtems/score/userext.h>
31#include <rtems/score/wkspace.h>
32#include <rtems/score/apiext.h>
33#include <rtems/score/sysstate.h>
34
35/*PAGE
36 *
37 *  rtems_task_wake_when
38 *
39 *  This directive blocks the requesting thread until the given date and
40 *  time is reached.
41 *
42 *  Input parameters:
43 *    time_buffer - pointer to the time and date structure
44 *
45 *  Output parameters:
46 *    RTEMS_SUCCESSFUL - if successful
47 *    error code       - if unsuccessful
48 */
49
50rtems_status_code rtems_task_wake_when(
51  rtems_time_of_day *time_buffer
52)
53{
54  Watchdog_Interval   seconds;
55
56  if ( !_TOD_Is_set )
57    return RTEMS_NOT_DEFINED;
58
59  if ( !time_buffer )
60    return RTEMS_INVALID_ADDRESS;
61
62  time_buffer->ticks = 0;
63
64  if ( !_TOD_Validate( time_buffer ) )
65    return RTEMS_INVALID_CLOCK;
66
67  seconds = _TOD_To_seconds( time_buffer );
68
69  if ( seconds <= _TOD_Seconds_since_epoch )
70    return RTEMS_INVALID_CLOCK;
71
72  _Thread_Disable_dispatch();
73    _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME );
74    _Watchdog_Initialize(
75      &_Thread_Executing->Timer,
76      _Thread_Delay_ended,
77      _Thread_Executing->Object.id,
78      NULL
79    );
80    _Watchdog_Insert_seconds(
81      &_Thread_Executing->Timer,
82      seconds - _TOD_Seconds_since_epoch
83    );
84  _Thread_Enable_dispatch();
85  return RTEMS_SUCCESSFUL;
86}
Note: See TracBrowser for help on using the repository browser.