source: rtems/doc/user/signal.t @ a94c5a5d

4.104.114.84.95
Last change on this file since a94c5a5d was a94c5a5d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/31/97 at 15:55:10

Changed bitwise OR's used to build up option and attribute sets
to be correct in either C or Ada.

Added the interrupt disable, enable, flash, and is in progress directives.

changed "97" to "1997"

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