Changeset c55df85 in rtems for cpukit


Ignore:
Timestamp:
Jan 16, 2002, 10:09:50 PM (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
de569fe
Parents:
3afb0d2
Message:

2001-01-16 Joel Sherrill <joel@…>

  • Added task-based timers to the Timer Manager. This added three new directives:
    • rtems_timer_initiate_server
    • rtems_timer_server_fire_after
    • rtems_timer_server_fire_when

In the process of doing this, a number of cleanups were made.

  • src/timerserver.c, src/timerserverfireafter.c, src/timerserverfirewhen.c: New files.
  • include/timer/timer.h: Added new prototypes and supporting types.
  • inline/rtems/rtems/timer.h, macros/rtems/rtems/timer.h: Enhanced _Timer_Is_interval_class() to cover the class TIMER_INTERVAL_ON_TASK.
  • src/Makefile.am: Accounted for new files.
  • src/rtemstimer.c: Added initialization of _Timer_Server variable.
  • src/timercancel.c, src/timerreset.c: Account for addition of timer classes. Also corrected the headers.
  • src/timercreate.c, src/timerdelete.c, src/timerfireafter.c, src/timerfireafter.c, src/timerident.c: Corrected header.
Location:
cpukit/rtems
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/ChangeLog

    r3afb0d2 rc55df85  
     12001-01-16      Joel Sherrill <joel@OARcorp.com>
     2
     3        * Added task-based timers to the Timer Manager.  This added three
     4        new directives:
     5            - rtems_timer_initiate_server
     6            - rtems_timer_server_fire_after
     7            - rtems_timer_server_fire_when
     8        In the process of doing this, a number of cleanups were made.
     9        * src/timerserver.c, src/timerserverfireafter.c,
     10        src/timerserverfirewhen.c: New files.
     11        * include/timer/timer.h: Added new prototypes and supporting types.
     12        * inline/rtems/rtems/timer.h, macros/rtems/rtems/timer.h: Enhanced
     13        _Timer_Is_interval_class() to cover the class TIMER_INTERVAL_ON_TASK.
     14        * src/Makefile.am: Accounted for new files.
     15        * src/rtemstimer.c: Added initialization of _Timer_Server variable.
     16        * src/timercancel.c, src/timerreset.c: Account for addition
     17        of timer classes.  Also corrected the headers.
     18        * src/timercreate.c, src/timerdelete.c, src/timerfireafter.c,
     19        src/timerfireafter.c, src/timerident.c: Corrected header.
     20
    1212001-01-16      Joel Sherrill <joel@OARcorp.com>
    222
  • cpukit/rtems/include/rtems/rtems/timer.h

    r3afb0d2 rc55df85  
    1111 *     + get an ID of a timer
    1212 *     + delete a timer
    13  *     + set a timer to fire after a number of ticks have passed
    14  *     + set a timer to fire when a specified date and time has been reached
     13 *     + set timer to fire in context of clock tick
     14 *        - after a number of ticks have passed
     15 *        - when a specified date and time has been reached
     16 *     + initiate the timer server task
     17 *     + set timer to fire in context of the timer server task
     18 *        - after a number of ticks have passed
     19 *        - when a specified date and time has been reached
    1520 *     + reset a timer
    1621 *     + cancel a time
    1722 *
    18  *  COPYRIGHT (c) 1989-1999.
     23 *  COPYRIGHT (c) 1989-2002.
    1924 *  On-Line Applications Research Corporation (OAR).
    2025 *
     
    3641#include <rtems/score/tod.h>
    3742#include <rtems/score/watchdog.h>
     43#include <rtems/rtems/attr.h>
    3844
    3945/*
     
    4450typedef enum {
    4551  TIMER_INTERVAL,
     52  TIMER_INTERVAL_ON_TASK,
    4653  TIMER_TIME_OF_DAY,
     54  TIMER_TIME_OF_DAY_ON_TASK,
    4755  TIMER_DORMANT
    4856} Timer_Classes;
     
    6775
    6876/*
     77 *  Pointer to TCB of the Timer Server.  This is NULL before the
     78 *  server is executing and task-based timers are not allowed to be
     79 *  initiated until the server is started.
     80 */
     81
     82RTEMS_EXTERN Thread_Control *_Timer_Server;
     83
     84/* 
     85 *  The following chains contain the list of interval timers that are
     86 *  executed in the context of the Timer Server.
     87 *
     88 *  NOTE: These are extern'ed because they do not have to be in the
     89 *        minimum footprint.  They are only really required when
     90 *        task-based timers are used.  Since task-based timers can
     91 *        not be started until the server is initiated, these structures
     92 *        do not have to be initialized until then.  They are declared
     93 *        in the same file as _Timer_Server_body.
     94 */   
     95
     96extern Chain_Control _Timer_Ticks_chain;
     97extern Chain_Control _Timer_Seconds_chain;
     98
     99/*
    69100 *  The following records define the control block used to manage
    70101 *  each timer.
     
    90121
    91122/*
     123 *  _Timer_Server_body
     124 *
     125 *  DESCRIPTION:
     126 *
     127 *  This is the server for task based timers.  This task executes whenever
     128 *  a task-based timer should fire.  It services both "after" and "when"
     129 *  timers.  It is not created automatically but must be created explicitly
     130 *  by the application before task-based timers may be initiated.
     131 */
     132
     133Thread _Timer_Server_body(
     134  unsigned32 ignored
     135);
     136
     137/*
     138 *  _Timer_Server_reset
     139 *
     140 *  DESCRIPTION:
     141 *
     142 *  This routine resets the timers which determine when the Timer Server
     143 *  will wake up next to service task-based timers.
     144 */
     145
     146typedef enum {
     147  TIMER_SERVER_RESET_TICKS,
     148  TIMER_SERVER_RESET_SECONDS
     149} Timer_Server_reset_mode;
     150
     151void _Timer_Server_reset(
     152  Timer_Server_reset_mode  reset_mode
     153);
     154
     155/*
    92156 *  rtems_timer_create
    93157 *
     
    152216 *
    153217 *  This routine implements the rtems_timer_fire_after directive.  It
    154  *  initiates the timer associated with ID to fire in ticks clock
    155  *  ticks.  When the timer fires, the routine will be invoked.
     218 *  initiates the timer associated with ID to fire in ticks clock ticks.
     219 *  When the timer fires, the routine will be invoked in the context
     220 *  of the rtems_clock_tick directive which is normally invoked as
     221 *  part of servicing a periodic interupt.
    156222 */
    157223
     
    164230
    165231/*
     232 *  rtems_timer_server_fire_after
     233 *
     234 *  DESCRIPTION:
     235 *
     236 *  This routine implements the rtems_timer_server_fire_after directive.  It
     237 *  initiates the timer associated with ID to fire in ticks clock
     238 *  ticks.  When the timer fires, the routine will be invoked by the
     239 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
     240 *  clock tick interrupt.
     241 */
     242
     243rtems_status_code rtems_timer_server_fire_after(
     244  Objects_Id                         id,
     245  rtems_interval                     ticks,
     246  rtems_timer_service_routine_entry  routine,
     247  void                              *user_data
     248);
     249
     250/*
    166251 *  rtems_timer_fire_when
    167252 *
     
    170255 *  This routine implements the rtems_timer_fire_when directive.  It
    171256 *  initiates the timer associated with ID to fire at wall_time
    172  *  When the timer fires, the routine will be invoked.
     257 *  When the timer fires, the routine will be invoked in the context
     258 *  of the rtems_clock_tick directive which is normally invoked as
     259 *  part of servicing a periodic interupt.
    173260 */
    174261
     
    181268
    182269/*
     270 *  rtems_timer_server_fire_when
     271 *
     272 *  DESCRIPTION:
     273 *
     274 *  This routine implements the rtems_timer_server_fire_when directive.  It
     275 *  initiates the timer associated with ID to fire at wall_time
     276 *  When the timer fires, the routine will be invoked by the
     277 *  Timer Server in the context of a task NOT IN THE CONTEXT of the
     278 *  clock tick interrupt.
     279 */
     280
     281rtems_status_code rtems_timer_server_fire_when(
     282  Objects_Id                          id,
     283  rtems_time_of_day                  *wall_time,
     284  rtems_timer_service_routine_entry   routine,
     285  void                               *user_data
     286);
     287
     288/*
    183289 *  rtems_timer_reset
    184290 *
     
    195301);
    196302
     303/*
     304 *  rtems_timer_initiate_server
     305 *
     306 *  DESCRIPTION:
     307 *
     308 *  This routine implements the rtems_timer_initiate_server directive.
     309 *  It creates and starts the server that executes task-based timers.
     310 *  It must be invoked before any task-based timers can be initiated.
     311 */
     312
     313rtems_status_code rtems_timer_initiate_server(
     314  unsigned32           stack_size,
     315  rtems_attribute      attribute_set
     316);
     317
    197318#ifndef __RTEMS_APPLICATION__
    198319#include <rtems/rtems/timer.inl>
  • cpukit/rtems/inline/rtems/rtems/timer.inl

    r3afb0d2 rc55df85  
    8585)
    8686{
    87   return ( the_class == TIMER_INTERVAL );
     87  return (the_class == TIMER_INTERVAL) || (the_class == TIMER_INTERVAL_ON_TASK);
    8888}
    8989
  • cpukit/rtems/macros/rtems/rtems/timer.inl

    r3afb0d2 rc55df85  
    5252
    5353#define _Timer_Is_interval_class( _the_class ) \
    54   ( (_the_class) == TIMER_INTERVAL )
     54  ( ((_the_class) == TIMER_INTERVAL) ||
     55    ((_the_class) == TIMER_INTERVAL_ON_TASK) )
    5556
    5657/*PAGE
  • cpukit/rtems/src/Makefile.am

    r3afb0d2 rc55df85  
    2727
    2828TIMER_C_FILES = rtemstimer.c timercancel.c timercreate.c timerdelete.c \
    29     timerfireafter.c timerfirewhen.c timerident.c timerreset.c
     29    timerfireafter.c timerfirewhen.c timerident.c timerreset.c timerserver.c \
     30    timerserverfireafter.c timerserverfirewhen.c
    3031
    3132MESSAGE_QUEUE_C_FILES = msg.c msgqallocate.c msgqbroadcast.c msgqcreate.c \
  • cpukit/rtems/src/rtemstimer.c

    r3afb0d2 rc55df85  
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4848    FALSE
    4949  );
     50
     51  /*
     52   *  Initialize the pointer to the Timer Server TCB to NULL indicating
     53   *  that task-based timer support is not initialized.
     54   */
     55
     56  _Timer_Server = NULL;
    5057}
  • cpukit/rtems/src/timercancel.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_cancel directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3333 *  Output parameters:
    3434 *    RTEMS_SUCCESSFUL - if successful
    35  *    error code - if unsuccessful
     35 *    error code       - if unsuccessful
    3636 */
    3737
  • cpukit/rtems/src/timercreate.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_create directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3333 *
    3434 *  Output parameters:
    35  *    id                - timer id
     35 *    id               - timer id
    3636 *    RTEMS_SUCCESSFUL - if successful
    37  *    error code        - if unsuccessful
     37 *    error code       - if unsuccessful
    3838 */
    3939
  • cpukit/rtems/src/timerdelete.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_delete directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3333 *  Output parameters:
    3434 *    RTEMS_SUCCESSFUL - if successful
    35  *    error code - if unsuccessful
     35 *    error code       - if unsuccessful
    3636 */
    3737
  • cpukit/rtems/src/timerfireafter.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_fire_after directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    2929 *
    3030 *  Input parameters:
    31  *    id      - timer id
    32  *    ticks   - interval until routine is fired
    33  *    routine - routine to schedule
     31 *    id        - timer id
     32 *    ticks     - interval until routine is fired
     33 *    routine   - routine to schedule
     34 *    user_data - passed as argument to routine when it is fired
    3435 *
    3536 *  Output parameters:
    3637 *    RTEMS_SUCCESSFUL - if successful
    37  *    error code        - if unsuccessful
     38 *    error code       - if unsuccessful
    3839 */
    3940
  • cpukit/rtems/src/timerfirewhen.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_fire_when directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3232 *    wall_time - time of day to fire timer
    3333 *    routine   - routine to schedule
     34 *    user_data - passed as argument to routine when it is fired
    3435 *
    3536 *  Output parameters:
    3637 *    RTEMS_SUCCESSFUL - if successful
    37  *    error code        - if unsuccessful
     38 *    error code       - if unsuccessful
    3839 */
    3940
  • cpukit/rtems/src/timerident.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_ident directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3434 *
    3535 *  Output parameters:
    36  *    *id               - message queue id
     36 *    *id              - message queue id
    3737 *    RTEMS_SUCCESSFUL - if successful
    38  *    error code        - if unsuccessful
     38 *    error code       - if unsuccessful
    3939 */
    4040
  • cpukit/rtems/src/timerreset.c

    r3afb0d2 rc55df85  
    11/*
    2  *  Timer Manager
     2 *  Timer Manager - rtems_timer_reset directive
    33 *
    44 *
    5  *  COPYRIGHT (c) 1989-1999.
     5 *  COPYRIGHT (c) 1989-2002.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    3333 *  Output parameters:
    3434 *    RTEMS_SUCCESSFUL - if successful
    35  *    error code        - if unsuccessful
     35 *    error code       - if unsuccessful
    3636 */
    3737
     
    5252
    5353    case OBJECTS_LOCAL:
    54       if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
    55         _Watchdog_Reset( &the_timer->Ticker );
    56         _Thread_Enable_dispatch();
    57         return RTEMS_SUCCESSFUL;
     54      switch ( the_timer->the_class ) {
     55        case TIMER_INTERVAL:
     56          _Watchdog_Remove( &the_timer->Ticker );
     57          _Watchdog_Insert( &_Watchdog_Ticks_chain, &the_timer->Ticker );
     58          break;
     59        case TIMER_INTERVAL_ON_TASK:
     60          _Watchdog_Remove( &the_timer->Ticker );
     61          _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
     62          break;
     63        case TIMER_TIME_OF_DAY:
     64        case TIMER_TIME_OF_DAY_ON_TASK:
     65        case TIMER_DORMANT:
     66          _Thread_Enable_dispatch();
     67          return RTEMS_NOT_DEFINED;
    5868      }
    5969      _Thread_Enable_dispatch();
    60       return RTEMS_NOT_DEFINED;
     70      return RTEMS_SUCCESSFUL;
    6171  }
    6272
Note: See TracChangeset for help on using the changeset viewer.