source: rtems/cpukit/rtems/src/taskwakeafter.c @ c499856

4.11
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Task Wake After
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/score/threadimpl.h>
23#include <rtems/score/schedulerimpl.h>
24#include <rtems/score/watchdogimpl.h>
25
26rtems_status_code rtems_task_wake_after(
27  rtems_interval ticks
28)
29{
30  /*
31   * It is critical to obtain the executing thread after thread dispatching is
32   * disabled on SMP configurations.
33   */
34  Thread_Control *executing;
35
36  _Thread_Disable_dispatch();
37    executing = _Thread_Executing;
38
39    if ( ticks == 0 ) {
40      _Scheduler_Yield( executing );
41    } else {
42      _Thread_Set_state( executing, STATES_DELAYING );
43      _Watchdog_Initialize(
44        &executing->Timer,
45        _Thread_Delay_ended,
46        executing->Object.id,
47        NULL
48      );
49      _Watchdog_Insert_ticks( &executing->Timer, ticks );
50    }
51  _Thread_Enable_dispatch();
52  return RTEMS_SUCCESSFUL;
53}
Note: See TracBrowser for help on using the repository browser.