source: rtems-docs/ada_user/signal_manager.rst @ 4783b0d

4.115
Last change on this file since 4783b0d was 4783b0d, checked in by Amar Takhar <amar@…>, on 01/17/16 at 16:37:28

Split document into seperate files by section.

  • Property mode set to 100644
File size: 11.3 KB
Line 
1Signal Manager
2##############
3
4.. index:: signals
5
6Introduction
7============
8
9The signal manager provides the capabilities required
10for asynchronous communication.  The directives provided by the
11signal manager are:
12
13- ``rtems.signal_catch`` - Establish an ASR
14
15- ``rtems.signal_send`` - Send signal set to a task
16
17Background
18==========
19
20Signal Manager Definitions
21--------------------------
22.. index:: asynchronous signal routine
23.. index:: ASR
24
25The signal manager allows a task to optionally define
26an asynchronous signal routine (ASR).  An ASR is to a task what
27an ISR is to an application’s set of tasks.  When the processor
28is interrupted, the execution of an application is also
29interrupted and an ISR is given control.  Similarly, when a
30signal is sent to a task, that task’s execution path will be
31"interrupted" by the ASR.  Sending a signal to a task has no
32effect on the receiving task’s current execution state... index:: rtems_signal_set
33
34A signal flag is used by a task (or ISR) to inform
35another task of the occurrence of a significant situation.
36Thirty-two signal flags are associated with each task.  A
37collection of one or more signals is referred to as a signal
38set.  The data type ``rtems.signal_set``
39is used to manipulate signal sets.
40
41A signal set is posted when it is directed (or sent) to a
42task. A pending signal is a signal that has been sent to a task
43with a valid ASR, but has not been processed by that task’s ASR.
44
45A Comparison of ASRs and ISRs
46-----------------------------
47.. index:: ASR vs. ISR
48.. index:: ISR vs. ASR
49
50The format of an ASR is similar to that of an ISR
51with the following exceptions:
52
53- ISRs are scheduled by the processor hardware.  ASRs are
54  scheduled by RTEMS.
55
56- ISRs do not execute in the context of a task and may
57  invoke only a subset of directives.  ASRs execute in the context
58  of a task and may execute any directive.
59
60- When an ISR is invoked, it is passed the vector number
61  as its argument.  When an ASR is invoked, it is passed the
62  signal set as its argument.
63
64- An ASR has a task mode which can be different from that
65  of the task.  An ISR does not execute as a task and, as a
66  result, does not have a task mode.
67
68Building a Signal Set
69---------------------
70.. index:: signal set, building
71
72A signal set is built by a bitwise OR of the desired
73signals.  The set of valid signals is ``RTEMS.SIGNAL_0`` through``RTEMS.SIGNAL_31``.  If a signal is not explicitly specified in the
74signal set, then it is not present.  Signal values are
75specifically designed to be mutually exclusive, therefore
76bitwise OR and addition operations are equivalent as long as
77each signal appears exactly once in the component list.
78
79This example demonstrates the signal parameter used
80when sending the signal set consisting of``RTEMS.SIGNAL_6``,``RTEMS.SIGNAL_15``, and``RTEMS.SIGNAL_31``.  The signal parameter provided
81to the ``rtems.signal_send`` directive should be``RTEMS.SIGNAL_6 or
82RTEMS.SIGNAL_15 or RTEMS.SIGNAL_31``.
83
84Building an ASR Mode
85--------------------
86.. index:: ASR mode, building
87
88In general, an ASR’s mode is built by a bitwise OR of
89the desired mode components.  The set of valid mode components
90is the same as those allowed with the task_create and task_mode
91directives.  A complete list of mode options is provided in the
92following table:
93
94- ``RTEMS.PREEMPT`` is masked by``RTEMS.PREEMPT_MASK`` and enables preemption
95
96- ``RTEMS.NO_PREEMPT`` is masked by``RTEMS.PREEMPT_MASK`` and disables preemption
97
98- ``RTEMS.NO_TIMESLICE`` is masked by``RTEMS.TIMESLICE_MASK`` and disables timeslicing
99
100- ``RTEMS.TIMESLICE`` is masked by``RTEMS.TIMESLICE_MASK`` and enables timeslicing
101
102- ``RTEMS.ASR`` is masked by``RTEMS.ASR_MASK`` and enables ASR processing
103
104- ``RTEMS.NO_ASR`` is masked by``RTEMS.ASR_MASK`` and disables ASR processing
105
106- ``RTEMS.INTERRUPT_LEVEL(0)`` is masked by``RTEMS.INTERRUPT_MASK`` and enables all interrupts
107
108- ``RTEMS.INTERRUPT_LEVEL(n)`` is masked by``RTEMS.INTERRUPT_MASK`` and sets interrupts level n
109
110Mode values are specifically designed to be mutually
111exclusive, therefore bitwise OR and addition operations are
112equivalent as long as each mode appears exactly once in the
113component list.  A mode component listed as a default is not
114required to appear in the mode list, although it is a good
115programming practice to specify default components.  If all
116defaults are desired, the mode DEFAULT_MODES should be specified
117on this call.
118
119This example demonstrates the mode parameter used
120with the ``rtems.signal_catch``
121to establish an ASR which executes at
122interrupt level three and is non-preemptible.  The mode should
123be set to``RTEMS.INTERRUPT_LEVEL(3) or RTEMS.NO_PREEMPT``
124to indicate the
125desired processor mode and interrupt level.
126
127Operations
128==========
129
130Establishing an ASR
131-------------------
132
133The ``rtems.signal_catch`` directive establishes an ASR for the
134calling task.  The address of the ASR and its execution mode are
135specified to this directive.  The ASR’s mode is distinct from
136the task’s mode.  For example, the task may allow preemption,
137while that task’s ASR may have preemption disabled.  Until a
138task calls ``rtems.signal_catch`` the first time,
139its ASR is invalid, and no signal sets can be sent to the task.
140
141A task may invalidate its ASR and discard all pending
142signals by calling ``rtems.signal_catch``
143with a value of NULL for the ASR’s address.  When a task’s
144ASR is invalid, new signal sets sent to this task are discarded.
145
146A task may disable ASR processing (``RTEMS.NO_ASR``) via the
147task_mode directive.  When a task’s ASR is disabled, the signals
148sent to it are left pending to be processed later when the ASR
149is enabled.
150
151Any directive that can be called from a task can also
152be called from an ASR.  A task is only allowed one active ASR.
153Thus, each call to ``rtems.signal_catch``
154replaces the previous one.
155
156Normally, signal processing is disabled for the ASR’s
157execution mode, but if signal processing is enabled for the ASR,
158the ASR must be reentrant.
159
160Sending a Signal Set
161--------------------
162
163The ``rtems.signal_send`` directive allows both
164tasks and ISRs to send signals to a target task.  The target task and
165a set of signals are specified to the``rtems.signal_send`` directive.  The sending
166of a signal to a task has no effect on the execution state of
167that task.  If the task is not the currently running task, then
168the signals are left pending and processed by the task’s ASR the
169next time the task is dispatched to run.  The ASR is executed
170immediately before the task is dispatched.  If the currently
171running task sends a signal to itself or is sent a signal from
172an ISR, its ASR is immediately dispatched to run provided signal
173processing is enabled.
174
175If an ASR with signals enabled is preempted by
176another task or an ISR and a new signal set is sent, then a new
177copy of the ASR will be invoked, nesting the preempted ASR.
178Upon completion of processing the new signal set, control will
179return to the preempted ASR.  In this situation, the ASR must be
180reentrant.
181
182Like events, identical signals sent to a task are not
183queued.  In other words, sending the same signal multiple times
184to a task (without any intermediate signal processing occurring
185for the task), has the same result as sending that signal to
186that task once.
187
188Processing an ASR
189-----------------
190
191Asynchronous signals were designed to provide the
192capability to generate software interrupts.  The processing of
193software interrupts parallels that of hardware interrupts.  As a
194result, the differences between the formats of ASRs and ISRs is
195limited to the meaning of the single argument passed to an ASR.
196The ASR should have the following calling sequence and adhere to
197Ada calling conventions:
198
199.. code:: c
200
201    procedure User_Routine (
202    Signals : in     RTEMS.Signal_Set
203    );
204
205When the ASR returns to RTEMS the mode and execution
206path of the interrupted task (or ASR) is restored to the context
207prior to entering the ASR.
208
209Directives
210==========
211
212This section details the signal manager’s directives.
213A subsection is dedicated to each of this manager’s directives
214and describes the calling sequence, related constants, usage,
215and status codes.
216
217SIGNAL_CATCH - Establish an ASR
218-------------------------------
219.. index:: establish an ASR
220.. index:: install an ASR
221
222**CALLING SEQUENCE:**
223
224.. code:: c
225
226    procedure Signal_Catch (
227    ASR_Handler : in     RTEMS.ASR_Handler;
228    Mode_Set    : in     RTEMS.Mode;
229    Result      :    out RTEMS.Status_Codes
230    );
231
232**DIRECTIVE STATUS CODES:**
233
234``RTEMS.SUCCESSFUL`` - always successful
235
236**DESCRIPTION:**
237
238This directive establishes an asynchronous signal
239routine (ASR) for the calling task.  The asr_handler parameter
240specifies the entry point of the ASR.  If asr_handler is NULL,
241the ASR for the calling task is invalidated and all pending
242signals are cleared.  Any signals sent to a task with an invalid
243ASR are discarded.  The mode parameter specifies the execution
244mode for the ASR.  This execution mode supersedes the task’s
245execution mode while the ASR is executing.
246
247**NOTES:**
248
249This directive will not cause the calling task to be
250preempted.
251
252The following task mode constants are defined by RTEMS:
253
254- ``RTEMS.PREEMPT`` is masked by``RTEMS.PREEMPT_MASK`` and enables preemption
255
256- ``RTEMS.NO_PREEMPT`` is masked by``RTEMS.PREEMPT_MASK`` and disables preemption
257
258- ``RTEMS.NO_TIMESLICE`` is masked by``RTEMS.TIMESLICE_MASK`` and disables timeslicing
259
260- ``RTEMS.TIMESLICE`` is masked by``RTEMS.TIMESLICE_MASK`` and enables timeslicing
261
262- ``RTEMS.ASR`` is masked by``RTEMS.ASR_MASK`` and enables ASR processing
263
264- ``RTEMS.NO_ASR`` is masked by``RTEMS.ASR_MASK`` and disables ASR processing
265
266- ``RTEMS.INTERRUPT_LEVEL(0)`` is masked by``RTEMS.INTERRUPT_MASK`` and enables all interrupts
267
268- ``RTEMS.INTERRUPT_LEVEL(n)`` is masked by``RTEMS.INTERRUPT_MASK`` and sets interrupts level n
269
270SIGNAL_SEND - Send signal set to a task
271---------------------------------------
272.. index:: send signal set
273
274**CALLING SEQUENCE:**
275
276.. code:: c
277
278    procedure Signal_Send (
279    ID         : in     RTEMS.ID;
280    Signal_Set : in     RTEMS.Signal_Set;
281    Result     :    out RTEMS.Status_Codes
282    );
283
284**DIRECTIVE STATUS CODES:**
285
286``RTEMS.SUCCESSFUL`` - signal sent successfully
287``RTEMS.INVALID_ID`` - task id invalid
288``RTEMS.INVALID_NUMBER`` - empty signal set
289``RTEMS.NOT_DEFINED`` - ASR invalid
290
291**DESCRIPTION:**
292
293This directive sends a signal set to the task
294specified in id.  The signal_set parameter contains the signal
295set to be sent to the task.
296
297If a caller sends a signal set to a task with an
298invalid ASR, then an error code is returned to the caller.  If a
299caller sends a signal set to a task whose ASR is valid but
300disabled, then the signal set will be caught and left pending
301for the ASR to process when it is enabled. If a caller sends a
302signal set to a task with an ASR that is both valid and enabled,
303then the signal set is caught and the ASR will execute the next
304time the task is dispatched to run.
305
306**NOTES:**
307
308Sending a signal set to a task has no effect on that
309task’s state.  If a signal set is sent to a blocked task, then
310the task will remain blocked and the signals will be processed
311when the task becomes the running task.
312
313Sending a signal set to a global task which does not
314reside on the local node will generate a request telling the
315remote node to send the signal set to the specified task.
316
317.. COMMENT: COPYRIGHT (c) 1988-2010.
318
319.. COMMENT: On-Line Applications Research Corporation (OAR).
320
321.. COMMENT: All rights reserved.
322
Note: See TracBrowser for help on using the repository browser.