OCEOS/oceos timed actions
Timed Actions (Software Timers)
Timed Actions Introduction
Timed actions (Software timers) provide directives to perform actions at a precise time in the future. The currently supported action types are:
- Timed output to memory address or register oceos_timed_output_add()
- Start task at a future time oceos_task_timed_start()
- Timeout for data queue pending job oceos_dataq_read_restart_timeout()
- Timeout for semaphore queue pending job oceos_sem_wait_restart_timeout()
The action types implemented in OCEOS are listed in the enumerated type below. The action types required by the user for oceos_timed_output_add() are WRITE_ACTION and RMW_ACTION. Other action types are provided for information only and are not available to the user.
1 enum ACTION_TYPE {
2 INVALID_ACION,
3 START_JOB_ACTION, // The job was created with start in future. Put job on ready Q
4 DATA_Q_WAIT_ACTION, // The job is on data_Q pending Q with timeout
5 SEM_Q_WAIT_ACTION, // The job is on semaphore_Q pending Q with timeout
6 WRITE_ACTION, // Write value to address
7 RMW_ACTION, // Read-modify-write Action
8 };
OCEOS uses the timed actions system to allow output of a value to an address be scheduled to occur independently of scheduling at a precise system time in microseconds.
Each output action involves (output address, value, type, mask, forward tolerance, backward tolerance, time).
When the timed action interrupt occurs this output and any other actions whose forward timing tolerances include the current time are performed. The backward tolerance allows the output be performed if the current time is later than the requested time by no more than this amount. If set to zero late outputs are not performed. Provision is made for error reporting if the current time is greater than the requested time by more than the allowed tolerance.
The output type and mask allow read-modify-write operations and single bit modifications.
Note
Timed outputs use the timed action subsystem which requires the user to provide some hardware specific timer initialization and handling.
All timed actions are put on timed action queue. This is a priority queue of pending actions and their associated times, with queue priority based on these times. It is linked to a high priority hardware timer which is set to interrupt at the time of the first action on the priority queue. When this interrupt occurs, actions on the queue within a timing tolerance of the current time are carried out and the timer is reset to interrupt at the start time of the earliest remaining action.
If the action is a task start request then at the set time the associated job is transferred to the ready queue, its origin set to timeout, and it is also removed from the pending list of any counting semaphore or data queue on which it is present. If the job is now the highest priority job on the ready queue it is started immediately, otherwise it must wait until that is the case.
If the action is a data output then at the set time it is performed immediately.
Timed Actions Configuration
SPARC
SPARC Timed Actions Configuration
ARM
ARM Timed Actions Configuration
User must define NUMBER_OF_SEMAPHORES. If NUMBER_OF_SEMAPHORES is zero, semaphores are not used. The example can be found in OCEOS demo projects.
#define NUMBER_OF_SEMAPHORES 2 /* * Create the application configuration structure */ struct application_configuration app_config = {0}; app_config.number_of_counting_semaphores = NUMBER_OF_SEMAPHORES;
API Functions
Directive | Description | main | task | IRQ handler |
---|---|---|---|---|
oceos_timed_jobs_number() | Get number of Jobs waiting on timed action queue | * | * | |
oceos_timed_jobs_remove() | Remove job from timed action queue | * | * | |
oceos_timed_jobs_reset() | Remove all jobs | * | * | |
oceos_timed_output_add() | Add output action to timed actions queue | * | * | |
oceos_timed_output_number() | Get number of timed output actions | * | * | |
oceos_timed_output_remove() | Remove timed output action from timed actions queue | * | * | |
oceos_timed_output_reset() | Remove all timed output actions | * | * |