Difference between revisions of "OCEOS/oceos timed actions"
Okhoruzhyy (talk | contribs) (Created page with "=<span style="color:#0000ff">'''Timed Actions (Software Timers)'''</span>= ==<span style="color:#0000ff">Introduction</span>== Category:backup") |
Okhoruzhyy (talk | contribs) |
||
Line 1: | Line 1: | ||
=<span style="color:#0000ff">'''Timed Actions (Software Timers)'''</span>= | =<span style="color:#0000ff">'''Timed Actions (Software Timers)'''</span>= | ||
==<span style="color:#0000ff">Introduction</span>== | ==<span style="color:#0000ff">Timed Actions Introduction</span>== | ||
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/oceos timed actions#oceos_timed_output_add()|oceos_timed_output_add()]] | |||
* Start task at a future time [[OCEOS/oceos kernel/task#oceos_task_timed_start()|oceos_task_timed_start()]] | |||
* Timeout for data queue pending job [[OCEOS/oceos inter-task communication/dataq#oceos_dataq_read_restart_timeout()|oceos_dataq_read_restart_timeout()]] | |||
* Timeout for semaphore queue pending job [[OCEOS/oceos inter-task communication/semaphore#oceos_sem_wait_restart_timeout()|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/oceos timed actions#oceos_timed_output_add()|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. | |||
<syntaxhighlight lang="C" line> | |||
enum ACTION_TYPE { | |||
INVALID_ACION, | |||
START_JOB_ACTION, // The job was created with start in future. Put job on ready Q | |||
DATA_Q_WAIT_ACTION, // The job is on data_Q pending Q with timeout | |||
SEM_Q_WAIT_ACTION, // The job is on semaphore_Q pending Q with timeout | |||
WRITE_ACTION, // Write value to address | |||
RMW_ACTION, // Read-modify-write Action | |||
}; | |||
</syntaxhighlight> | |||
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.<br> | |||
Each output action involves (output address, value, type, mask, forward tolerance, backward tolerance, time).<br> | |||
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. | |||
<blockquote style="background-color: #c6e2f7; border-left-style: solid; border-left-width: 3px; border-left-color: blue; "> '''Note'''<br> | |||
Timed outputs use the timed action subsystem which requires the user to provide some hardware specific timer initialization and handling. | |||
</blockquote> | |||
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. | |||
==<span style="color:#0000ff">Timed Actions Configuration</span>== | |||
<blockquote> | |||
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.<br> | |||
<syntaxhighlight lang="C"> | |||
#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; | |||
</syntaxhighlight> | |||
</blockquote> | |||
==<span style="color:#0000ff">API Functions</span>== | |||
{| class="wikitable" | |||
|+ API Functions | |||
|- | |||
! Directive !! Description !! main !! task !! IRQ handler | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_create()|oceos_sem_create()]] || Create semaphore || * || || | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_signal()|oceos_sem_signal()]] || Signals a semaphore || || * || * | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_wait_continue()|oceos_sem_wait_continue()]] || Wait on semaphore || || * || | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_wait_restart()|oceos_sem_wait_restart()]] || Wait on semaphore || || * || | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_wait_restart_timeout()|oceos_sem_wait_restart_timeout()]]|| Wait on semaphore || || * || | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_get_value()|oceos_sem_get_value()]] || Returns number of available permits || || * || * | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_penq_get_size()|oceos_sem_penq_get_size()]] || Returns number of jobs on semaphore pending queue || || * || * | |||
|- | |||
| [[OCEOS/oceos_inter-task_communication/semaphore#oceos_sem_reset()|oceos_sem_reset()]] || Restore permits to original value and frees tasks on pending queue || || * || * | |||
|} | |||
[[Category:backup]] | [[Category:backup]] |
Revision as of 17:34, 23 March 2022
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
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_sem_create() | Create semaphore | * | ||
oceos_sem_signal() | Signals a semaphore | * | * | |
oceos_sem_wait_continue() | Wait on semaphore | * | ||
oceos_sem_wait_restart() | Wait on semaphore | * | ||
oceos_sem_wait_restart_timeout() | Wait on semaphore | * | ||
oceos_sem_get_value() | Returns number of available permits | * | * | |
oceos_sem_penq_get_size() | Returns number of jobs on semaphore pending queue | * | * | |
oceos_sem_reset() | Restore permits to original value and frees tasks on pending queue | * | * |