diff options
Diffstat (limited to 'c-user/signal')
-rw-r--r-- | c-user/signal/background.rst | 112 | ||||
-rw-r--r-- | c-user/signal/directives.rst | 198 | ||||
-rw-r--r-- | c-user/signal/index.rst | 17 | ||||
-rw-r--r-- | c-user/signal/introduction.rst | 38 | ||||
-rw-r--r-- | c-user/signal/operations.rst | 75 |
5 files changed, 440 insertions, 0 deletions
diff --git a/c-user/signal/background.rst b/c-user/signal/background.rst new file mode 100644 index 0000000..5ba5eeb --- /dev/null +++ b/c-user/signal/background.rst @@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) + +Background +========== + +.. index:: asynchronous signal routine +.. index:: ASR + +Signal Manager Definitions +-------------------------- + +The signal manager allows a task to optionally define an asynchronous signal +routine (ASR). An ASR is to a task what an ISR is to an application's set of +tasks. When the processor is interrupted, the execution of an application is +also interrupted and an ISR is given control. Similarly, when a signal is sent +to a task, that task's execution path will be "interrupted" by the ASR. +Sending a signal to a task has no effect on the receiving task's current +execution state. + +.. index:: rtems_signal_set + +A signal flag is used by a task (or ISR) to inform another task of the +occurrence of a significant situation. Thirty-two signal flags are associated +with each task. A collection of one or more signals is referred to as a signal +set. The data type ``rtems_signal_set`` is used to manipulate signal sets. + +A signal set is posted when it is directed (or sent) to a task. A pending +signal is a signal that has been sent to a task with a valid ASR, but has not +been processed by that task's ASR. + +.. index:: ASR vs. ISR +.. index:: ISR vs. ASR + +A Comparison of ASRs and ISRs +----------------------------- + +The format of an ASR is similar to that of an ISR with the following +exceptions: + +- ISRs are scheduled by the processor hardware. ASRs are scheduled by RTEMS. + +- ISRs do not execute in the context of a task and may invoke only a subset of + directives. ASRs execute in the context of a task and may execute any + directive. + +- When an ISR is invoked, it is passed the vector number as its argument. When + an ASR is invoked, it is passed the signal set as its argument. + +- An ASR has a task mode which can be different from that of the task. An ISR + does not execute as a task and, as a result, does not have a task mode. + +.. index:: signal set, building + +Building a Signal Set +--------------------- + +A signal set is built by a bitwise OR of the desired signals. The set of valid +signals is ``RTEMS_SIGNAL_0`` through ``RTEMS_SIGNAL_31``. If a signal is not +explicitly specified in the signal set, then it is not present. Signal values +are specifically designed to be mutually exclusive, therefore bitwise OR and +addition operations are equivalent as long as each signal appears exactly once +in the component list. + +This example demonstrates the signal parameter used when sending the signal set +consisting of ``RTEMS_SIGNAL_6``, ``RTEMS_SIGNAL_15``, and ``RTEMS_SIGNAL_31``. +The signal parameter provided to the ``rtems_signal_send`` directive should be +``RTEMS_SIGNAL_6 | RTEMS_SIGNAL_15 | RTEMS_SIGNAL_31``. + +.. index:: ASR mode, building + +Building an ASR Mode +-------------------- + +In general, an ASR's mode is built by a bitwise OR of the desired mode +components. The set of valid mode components is the same as those allowed with +the task_create and task_mode directives. A complete list of mode options is +provided in the following table: + +.. list-table:: + :class: rtems-table + + * - ``RTEMS_PREEMPT`` + - is masked by ``RTEMS_PREEMPT_MASK`` and enables preemption + * - ``RTEMS_NO_PREEMPT`` + - is masked by ``RTEMS_PREEMPT_MASK`` and disables preemption + * - ``RTEMS_NO_TIMESLICE`` + - is masked by ``RTEMS_TIMESLICE_MASK`` and disables timeslicing + * - ``RTEMS_TIMESLICE`` + - is masked by ``RTEMS_TIMESLICE_MASK`` and enables timeslicing + * - ``RTEMS_ASR`` + - is masked by ``RTEMS_ASR_MASK`` and enables ASR processing + * - ``RTEMS_NO_ASR`` + - is masked by ``RTEMS_ASR_MASK`` and disables ASR processing + * - ``RTEMS_INTERRUPT_LEVEL(0)`` + - is masked by ``RTEMS_INTERRUPT_MASK`` and enables all interrupts + * - ``RTEMS_INTERRUPT_LEVEL(n)`` + - is masked by ``RTEMS_INTERRUPT_MASK`` and sets interrupts level n + +Mode values are specifically designed to be mutually exclusive, therefore +bitwise OR and addition operations are equivalent as long as each mode appears +exactly once in the component list. A mode component listed as a default is +not required to appear in the mode list, although it is a good programming +practice to specify default components. If all defaults are desired, the mode +``DEFAULT_MODES`` should be specified on this call. + +This example demonstrates the mode parameter used with the +``rtems_signal_catch`` to establish an ASR which executes at interrupt level +three and is non-preemptible. The mode should be set to +``RTEMS_INTERRUPT_LEVEL(3) | RTEMS_NO_PREEMPT`` to indicate the desired +processor mode and interrupt level. diff --git a/c-user/signal/directives.rst b/c-user/signal/directives.rst new file mode 100644 index 0000000..9345132 --- /dev/null +++ b/c-user/signal/directives.rst @@ -0,0 +1,198 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG +.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) + +.. This file is part of the RTEMS quality process and was automatically +.. generated. If you find something that needs to be fixed or +.. worded better please post a report or patch to an RTEMS mailing list +.. or raise a bug report: +.. +.. https://www.rtems.org/bugs.html +.. +.. For information on updating and regenerating please refer to the How-To +.. section in the Software Requirements Engineering chapter of the +.. RTEMS Software Engineering manual. The manual is provided as a part of +.. a release. For development sources please refer to the online +.. documentation at: +.. +.. https://docs.rtems.org + +.. _SignalManagerDirectives: + +Directives +========== + +This section details the directives of the Signal Manager. A subsection is +dedicated to each of this manager's directives and lists the calling sequence, +parameters, description, return values, and notes of the directive. + +.. Generated from spec:/rtems/signal/if/catch + +.. raw:: latex + + \clearpage + +.. index:: rtems_signal_catch() +.. index:: establish an ASR +.. index:: install an ASR + +.. _InterfaceRtemsSignalCatch: + +rtems_signal_catch() +-------------------- + +Establishes an asynchronous signal routine (ASR) for the calling task. + +.. rubric:: CALLING SEQUENCE: + +.. code-block:: c + + rtems_status_code rtems_signal_catch( + rtems_asr_entry asr_handler, + rtems_mode mode_set + ); + +.. rubric:: PARAMETERS: + +``asr_handler`` + This parameter is the handler to process an asynchronous signal set. + +``mode_set`` + This parameter is the task mode while an asynchronous signal set is + processed by the handler. See :ref:`InterfaceRtemsTaskMode`. + +.. rubric:: DESCRIPTION: + +This directive establishes an asynchronous signal routine (ASR) for the calling +task. The ``asr_handler`` parameter specifies the entry point of the ASR. A +task may have at most one handler installed at a time. The most recently +installed handler is used. When ``asr_handler`` is `NULL +<https://en.cppreference.com/w/c/types/NULL>`_, the ASR for the calling task is +invalidated and all pending signals are cleared. Any signals sent to a task +with an invalid ASR are discarded. The ``mode_set`` parameter specifies the +execution mode for the ASR. This execution mode supersedes the task's +execution mode while the ASR is executing. + +.. rubric:: RETURN VALUES: + +:c:macro:`RTEMS_SUCCESSFUL` + The requested operation was successful. + +:c:macro:`RTEMS_NOT_IMPLEMENTED` + The :c:macro:`RTEMS_NO_PREEMPT` was set in ``mode_set`` and the system + configuration had no implementation for this mode. + +:c:macro:`RTEMS_NOT_IMPLEMENTED` + The :c:func:`RTEMS_INTERRUPT_LEVEL` was set to a positive level in + ``mode_set`` and the system configuration had no implementation for this + mode. + +.. rubric:: NOTES: + +It is strongly recommended to disable ASR processing during ASR processing by +setting :c:macro:`RTEMS_NO_ASR` in ``mode_set``, otherwise a recursion may +happen during ASR processing. Uncontrolled recursion may lead to stack +overflows. + +Using the same mutex (in particular a recursive mutex) in normal task context +and during ASR processing may result in undefined behaviour. + +Asynchronous signal handlers can access thread-local storage (:term:`TLS`). +When thread-local storage is shared between normal task context and ASR +processing, it may be protected by disabled interrupts. + +.. rubric:: CONSTRAINTS: + +The following constraints apply to this directive: + +* The directive may be called from within task context. + +* The directive will not cause the calling task to be preempted. + +.. Generated from spec:/rtems/signal/if/send + +.. raw:: latex + + \clearpage + +.. index:: rtems_signal_send() +.. index:: send signal set + +.. _InterfaceRtemsSignalSend: + +rtems_signal_send() +------------------- + +Sends the signal set to the task. + +.. rubric:: CALLING SEQUENCE: + +.. code-block:: c + + rtems_status_code rtems_signal_send( + rtems_id id, + rtems_signal_set signal_set + ); + +.. rubric:: PARAMETERS: + +``id`` + This parameter is the identifier of the target task to receive the signal + set. + +``signal_set`` + This parameter is the signal set to send. + +.. rubric:: DESCRIPTION: + +This directive sends the signal set, ``signal_set``, to the target task +identified by ``id``. + +If a caller sends a signal set to a task with an invalid :term:`ASR`, then an +error code is returned to the caller. If a caller sends a signal set to a task +whose ASR is valid but disabled, then the signal set will be caught and left +pending for the ASR to process when it is enabled. If a caller sends a signal +set to a task with an ASR that is both valid and enabled, then the signal set +is caught and the ASR will execute the next time the task is dispatched to run. + +.. rubric:: RETURN VALUES: + +:c:macro:`RTEMS_SUCCESSFUL` + The requested operation was successful. + +:c:macro:`RTEMS_INVALID_NUMBER` + The ``signal_set`` parameter was 0. + +:c:macro:`RTEMS_INVALID_ID` + There was no task associated with the identifier specified by ``id``. + +:c:macro:`RTEMS_NOT_DEFINED` + The target task had no valid ASR installed. + +.. rubric:: NOTES: + +Sending a signal set to a task has no effect on that task's state. If a signal +set is sent to a blocked task, then the task will remain blocked and the +signals will be processed when the task becomes the running task. + +Sending a signal set to a global task which does not reside on the local node +will generate a request telling the remote node to send the signal set to the +specified task. + +.. rubric:: CONSTRAINTS: + +The following constraints apply to this directive: + +* The directive may be called from within interrupt context. + +* The directive may be called from within device driver initialization context. + +* The directive may be called from within task context. + +* When the directive operates on a local object, the directive will not cause + the calling task to be preempted. + +* When the directive operates on a remote object, the directive sends a message + to the remote node and waits for a reply. This will preempt the calling + task. diff --git a/c-user/signal/index.rst b/c-user/signal/index.rst new file mode 100644 index 0000000..d52e098 --- /dev/null +++ b/c-user/signal/index.rst @@ -0,0 +1,17 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. Copyright (C) 2020 embedded brains GmbH & Co. KG + +.. index:: signals + +.. _RTEMSAPIClassicSignal: + +Signal Manager +************** + +.. toctree:: + + introduction + background + operations + directives diff --git a/c-user/signal/introduction.rst b/c-user/signal/introduction.rst new file mode 100644 index 0000000..f6e0ded --- /dev/null +++ b/c-user/signal/introduction.rst @@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG +.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) + +.. This file is part of the RTEMS quality process and was automatically +.. generated. If you find something that needs to be fixed or +.. worded better please post a report or patch to an RTEMS mailing list +.. or raise a bug report: +.. +.. https://www.rtems.org/bugs.html +.. +.. For information on updating and regenerating please refer to the How-To +.. section in the Software Requirements Engineering chapter of the +.. RTEMS Software Engineering manual. The manual is provided as a part of +.. a release. For development sources please refer to the online +.. documentation at: +.. +.. https://docs.rtems.org + +.. Generated from spec:/rtems/signal/if/group + +.. _SignalManagerIntroduction: + +Introduction +============ + +.. The following list was generated from: +.. spec:/rtems/signal/if/catch +.. spec:/rtems/signal/if/send + +The Signal Manager provides the capabilities required for asynchronous +communication. The directives provided by the Signal Manager are: + +* :ref:`InterfaceRtemsSignalCatch` - Establishes an asynchronous signal routine + (ASR) for the calling task. + +* :ref:`InterfaceRtemsSignalSend` - Sends the signal set to the task. diff --git a/c-user/signal/operations.rst b/c-user/signal/operations.rst new file mode 100644 index 0000000..967b35f --- /dev/null +++ b/c-user/signal/operations.rst @@ -0,0 +1,75 @@ +.. SPDX-License-Identifier: CC-BY-SA-4.0 + +.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) + +Operations +========== + +Establishing an ASR +------------------- + +The ``rtems_signal_catch`` directive establishes an ASR for the calling task. +The address of the ASR and its execution mode are specified to this directive. +The ASR's mode is distinct from the task's mode. For example, the task may +allow preemption, while that task's ASR may have preemption disabled. Until a +task calls ``rtems_signal_catch`` the first time, its ASR is invalid, and no +signal sets can be sent to the task. + +A task may invalidate its ASR and discard all pending signals by calling +``rtems_signal_catch`` with a value of NULL for the ASR's address. When a +task's ASR is invalid, new signal sets sent to this task are discarded. + +A task may disable ASR processing (``RTEMS_NO_ASR``) via the task_mode +directive. When a task's ASR is disabled, the signals sent to it are left +pending to be processed later when the ASR is enabled. + +Any directive that can be called from a task can also be called from an ASR. A +task is only allowed one active ASR. Thus, each call to ``rtems_signal_catch`` +replaces the previous one. + +Normally, signal processing is disabled for the ASR's execution mode, but if +signal processing is enabled for the ASR, the ASR must be reentrant. + +Sending a Signal Set +-------------------- + +The ``rtems_signal_send`` directive allows both tasks and ISRs to send signals +to a target task. The target task and a set of signals are specified to the +``rtems_signal_send`` directive. The sending of a signal to a task has no +effect on the execution state of that task. If the task is not the currently +running task, then the signals are left pending and processed by the task's ASR +the next time the task is dispatched to run. The ASR is executed immediately +before the task is dispatched. If the currently running task sends a signal to +itself or is sent a signal from an ISR, its ASR is immediately dispatched to +run provided signal processing is enabled. + +If an ASR with signals enabled is preempted by another task or an ISR and a new +signal set is sent, then a new copy of the ASR will be invoked, nesting the +preempted ASR. Upon completion of processing the new signal set, control will +return to the preempted ASR. In this situation, the ASR must be reentrant. + +Like events, identical signals sent to a task are not queued. In other words, +sending the same signal multiple times to a task (without any intermediate +signal processing occurring for the task), has the same result as sending that +signal to that task once. + +.. index:: rtems_asr + +Processing an ASR +----------------- + +Asynchronous signals were designed to provide the capability to generate +software interrupts. The processing of software interrupts parallels that of +hardware interrupts. As a result, the differences between the formats of ASRs +and ISRs is limited to the meaning of the single argument passed to an ASR. +The ASR should have the following calling sequence and adhere to C calling +conventions: + +.. code-block:: c + + rtems_asr user_routine( + rtems_signal_set signals + ); + +When the ASR returns to RTEMS the mode and execution path of the interrupted +task (or ASR) is restored to the context prior to entering the ASR. |