source: rtems/cpukit/rtems/src/timerserverfireafter.c @ 2d2352b

4.115
Last change on this file since 2d2352b was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Timer Server Fire After
5 *  @ingroup ClassicTimer
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.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/score/object.h>
25#include <rtems/score/thread.h>
26#include <rtems/rtems/timer.h>
27#include <rtems/score/tod.h>
28#include <rtems/score/watchdog.h>
29
30rtems_status_code rtems_timer_server_fire_after(
31  rtems_id                           id,
32  rtems_interval                     ticks,
33  rtems_timer_service_routine_entry  routine,
34  void                              *user_data
35)
36{
37  Timer_Control        *the_timer;
38  Objects_Locations     location;
39  ISR_Level             level;
40  Timer_server_Control *timer_server = _Timer_server;
41
42  if ( !timer_server )
43    return RTEMS_INCORRECT_STATE;
44
45  if ( !routine )
46    return RTEMS_INVALID_ADDRESS;
47
48  if ( ticks == 0 )
49    return RTEMS_INVALID_NUMBER;
50
51  the_timer = _Timer_Get( id, &location );
52  switch ( location ) {
53
54    case OBJECTS_LOCAL:
55      (void) _Watchdog_Remove( &the_timer->Ticker );
56
57      _ISR_Disable( level );
58
59        /*
60         *  Check to see if the watchdog has just been inserted by a
61         *  higher priority interrupt.  If so, abandon this insert.
62         */
63
64        if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
65          _ISR_Enable( level );
66          _Objects_Put( &the_timer->Object );
67          return RTEMS_SUCCESSFUL;
68        }
69
70        /*
71         *  OK.  Now we now the timer was not rescheduled by an interrupt
72         *  so we can atomically initialize it as in use.
73         */
74
75        the_timer->the_class = TIMER_INTERVAL_ON_TASK;
76        _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
77        the_timer->Ticker.initial = ticks;
78      _ISR_Enable( level );
79
80      (*timer_server->schedule_operation)( timer_server, the_timer );
81
82      _Objects_Put( &the_timer->Object );
83      return RTEMS_SUCCESSFUL;
84
85#if defined(RTEMS_MULTIPROCESSING)
86    case OBJECTS_REMOTE:            /* should never return this */
87#endif
88    case OBJECTS_ERROR:
89      break;
90  }
91
92  return RTEMS_INVALID_ID;
93}
Note: See TracBrowser for help on using the repository browser.