source: rtems/cpukit/rtems/src/timerfireafter.c @ 860c34e

4.104.114.95
Last change on this file since 860c34e was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on 11/30/07 at 20:34:13

2007-11-30 Glenn Humphrey <glenn.humphrey@…>

  • posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes.
  • posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files.
  • posix/src/mutexfromcorestatus.c: Removed.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Timer Manager - rtems_timer_fire_after 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_fire_after
31 *
32 *  This directive allows a thread to start a timer.
33 *
34 *  Input parameters:
35 *    id        - timer id
36 *    ticks     - interval until routine is fired
37 *    routine   - routine to schedule
38 *    user_data - passed as argument to routine when it is fired
39 *
40 *  Output parameters:
41 *    RTEMS_SUCCESSFUL - if successful
42 *    error code       - if unsuccessful
43 */
44
45rtems_status_code rtems_timer_fire_after(
46  Objects_Id                         id,
47  rtems_interval                     ticks,
48  rtems_timer_service_routine_entry  routine,
49  void                              *user_data
50)
51{
52  Timer_Control      *the_timer;
53  Objects_Locations   location;
54  ISR_Level           level;
55
56  if ( ticks == 0 )
57    return RTEMS_INVALID_NUMBER;
58
59  if ( !routine )
60    return RTEMS_INVALID_ADDRESS;
61
62  the_timer = _Timer_Get( id, &location );
63  switch ( location ) {
64
65    case OBJECTS_LOCAL:
66      (void) _Watchdog_Remove( &the_timer->Ticker );
67
68      _ISR_Disable( level );
69
70        /*
71         *  Check to see if the watchdog has just been inserted by a
72         *  higher priority interrupt.  If so, abandon this insert.
73         */
74
75        if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
76          _ISR_Enable( level );
77          _Thread_Enable_dispatch();
78          return RTEMS_SUCCESSFUL;
79        }
80
81        /*
82         *  OK.  Now we now the timer was not rescheduled by an interrupt
83         *  so we can atomically initialize it as in use.
84         */
85
86        the_timer->the_class = TIMER_INTERVAL;
87        _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
88      _ISR_Enable( level );
89
90
91      _Watchdog_Insert_ticks( &the_timer->Ticker, ticks );
92      _Thread_Enable_dispatch();
93      return RTEMS_SUCCESSFUL;
94
95#if defined(RTEMS_MULTIPROCESSING)
96    case OBJECTS_REMOTE:            /* should never return this */
97#endif
98    case OBJECTS_ERROR:
99      break;
100  }
101
102  return RTEMS_INVALID_ID;
103}
Note: See TracBrowser for help on using the repository browser.