source: rtems/cpukit/rtems/src/timerreset.c @ 63b3dff5

4.104.115
Last change on this file since 63b3dff5 was 63b3dff5, checked in by Joel Sherrill <joel.sherrill@…>, on 08/18/09 at 15:35:51

2009-08-18 Joel Sherrill <joel.sherrill@…>

  • rtems/src/timerreset.c: Rework to ease analysis.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  Timer Manager - rtems_timer_reset directive
3 *
4 *
5 *  COPYRIGHT (c) 1989-2007.
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/score/object.h>
23#include <rtems/score/thread.h>
24#include <rtems/rtems/timer.h>
25#include <rtems/score/tod.h>
26#include <rtems/score/watchdog.h>
27
28/*PAGE
29 *
30 *  rtems_timer_reset
31 *
32 *  This directive allows a thread to reset a timer.
33 *
34 *  Input parameters:
35 *    id - timer id
36 *
37 *  Output parameters:
38 *    RTEMS_SUCCESSFUL - if successful
39 *    error code       - if unsuccessful
40 */
41
42rtems_status_code rtems_timer_reset(
43  Objects_Id id
44)
45{
46  Timer_Control     *the_timer;
47  Objects_Locations  location;
48  rtems_status_code  status = RTEMS_SUCCESSFUL;
49
50  the_timer = _Timer_Get( id, &location );
51  switch ( location ) {
52
53    case OBJECTS_LOCAL:
54      if ( the_timer->the_class == TIMER_INTERVAL ) {
55        _Watchdog_Remove( &the_timer->Ticker );
56        _Watchdog_Insert( &_Watchdog_Ticks_chain, &the_timer->Ticker );
57      } else if ( the_timer->the_class == TIMER_INTERVAL_ON_TASK ) {
58        /*
59         *  There is no way for a timer to have this class unless
60         *  it was scheduled as a server fire.  That requires that
61         *  the Timer Server be initiated.  So this error cannot
62         *  occur unless something is internally wrong.
63         */
64        #if defined(RTEMS_DEBUG)
65          if ( !_Timer_Server_schedule_operation ) {
66            _Thread_Enable_dispatch();
67            return RTEMS_INCORRECT_STATE;
68          }
69        #endif
70        _Watchdog_Remove( &the_timer->Ticker );
71        (*_Timer_Server_schedule_operation)( the_timer );
72      } else {
73        /*
74         *  Must be dormant or time of day timer (e.g. TIMER_DORMANT,
75         *  TIMER_TIME_OF_DAY, or TIMER_TIME_OF_DAY_ON_TASK).  We
76         *  can only reset active interval timers.
77         */
78        status = RTEMS_NOT_DEFINED;
79      }
80      _Thread_Enable_dispatch();
81      return status;
82
83#if defined(RTEMS_MULTIPROCESSING)
84    case OBJECTS_REMOTE:            /* should never return this */
85#endif
86    case OBJECTS_ERROR:
87      break;
88  }
89
90  return RTEMS_INVALID_ID;
91}
Note: See TracBrowser for help on using the repository browser.