source: rtems/cpukit/rtems/src/timerreset.c @ 03b900d

5
Last change on this file since 03b900d 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.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Timer Reset
5 * @ingroup ClassicTimer Timers
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/thread.h>
25#include <rtems/rtems/timerimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28/*
29 *  rtems_timer_reset
30 *
31 *  This directive allows a thread to reset a timer.
32 *
33 *  Input parameters:
34 *    id - timer id
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code       - if unsuccessful
39 */
40
41rtems_status_code rtems_timer_reset(
42  rtems_id id
43)
44{
45  Timer_Control     *the_timer;
46  Objects_Locations  location;
47  ISR_lock_Context   lock_context;
48  Per_CPU_Control   *cpu;
49  rtems_status_code  status;
50
51  the_timer = _Timer_Get( id, &location, &lock_context );
52  switch ( location ) {
53
54    case OBJECTS_LOCAL:
55      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
56
57      if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
58        _Timer_Cancel( cpu, the_timer );
59        _Watchdog_Insert(
60          &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
61          &the_timer->Ticker,
62          cpu->Watchdog.ticks + the_timer->initial
63        );
64        status = RTEMS_SUCCESSFUL;
65      } else {
66        status = RTEMS_NOT_DEFINED;
67      }
68
69      _Timer_Release( cpu, &lock_context );
70      return status;
71
72#if defined(RTEMS_MULTIPROCESSING)
73    case OBJECTS_REMOTE:            /* should never return this */
74#endif
75    case OBJECTS_ERROR:
76      break;
77  }
78
79  return RTEMS_INVALID_ID;
80}
Note: See TracBrowser for help on using the repository browser.