source: rtems/cpukit/rtems/src/taskwakeafter.c @ 6eba7c85

4.115
Last change on this file since 6eba7c85 was 6eba7c85, checked in by Sebastian Huber <sebastian.huber@…>, on 06/10/13 at 14:15:46

scheduler: Specify thread of yield operation

The yielding thread of the yield operation is now specified by a
parameter. The tick operation may be performed for each executing
thread in a SMP configuration.

  • Property mode set to 100644
File size: 1.5 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/rtems/modes.h>
25#include <rtems/score/object.h>
26#include <rtems/score/scheduler.h>
27#include <rtems/score/stack.h>
28#include <rtems/score/states.h>
29#include <rtems/rtems/tasks.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/threadq.h>
32#include <rtems/score/tod.h>
33#include <rtems/score/wkspace.h>
34#include <rtems/score/apiext.h>
35#include <rtems/score/sysstate.h>
36
37rtems_status_code rtems_task_wake_after(
38  rtems_interval ticks
39)
40{
41  /*
42   * It is critical to obtain the executing thread after thread dispatching is
43   * disabled on SMP configurations.
44   */
45  Thread_Control *executing;
46
47  _Thread_Disable_dispatch();
48    executing = _Thread_Executing;
49
50    if ( ticks == 0 ) {
51      _Scheduler_Yield( executing );
52    } else {
53      _Thread_Set_state( executing, STATES_DELAYING );
54      _Watchdog_Initialize(
55        &executing->Timer,
56        _Thread_Delay_ended,
57        executing->Object.id,
58        NULL
59      );
60      _Watchdog_Insert_ticks( &executing->Timer, ticks );
61    }
62  _Thread_Enable_dispatch();
63  return RTEMS_SUCCESSFUL;
64}
Note: See TracBrowser for help on using the repository browser.