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

5
Last change on this file since d78d529 was 03b900d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/16 at 07:36:26

score: Replace watchdog handler implementation

Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Task Wake When
5 *  @ingroup ClassicTasks
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/tasks.h>
22#include <rtems/rtems/clock.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/score/todimpl.h>
25#include <rtems/score/watchdogimpl.h>
26
27rtems_status_code rtems_task_wake_when(
28  rtems_time_of_day *time_buffer
29)
30{
31  uint32_t         seconds;
32  Thread_Control  *executing;
33  Per_CPU_Control *cpu_self;
34
35  if ( !_TOD_Is_set() )
36    return RTEMS_NOT_DEFINED;
37
38  if ( !time_buffer )
39    return RTEMS_INVALID_ADDRESS;
40
41  time_buffer->ticks = 0;
42
43  if ( !_TOD_Validate( time_buffer ) )
44    return RTEMS_INVALID_CLOCK;
45
46  seconds = _TOD_To_seconds( time_buffer );
47
48  if ( seconds <= _TOD_Seconds_since_epoch() )
49    return RTEMS_INVALID_CLOCK;
50
51  cpu_self = _Thread_Dispatch_disable();
52    executing = _Thread_Executing;
53    _Thread_Set_state( executing, STATES_WAITING_FOR_TIME );
54    _Thread_Wait_flags_set( executing, THREAD_WAIT_STATE_BLOCKED );
55    _Thread_Timer_insert_absolute(
56      executing,
57      cpu_self,
58      _Thread_Timeout,
59      _Watchdog_Ticks_from_seconds( seconds )
60    );
61  _Thread_Dispatch_enable( cpu_self );
62  return RTEMS_SUCCESSFUL;
63}
Note: See TracBrowser for help on using the repository browser.