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

4.104.114.84.95
Last change on this file since a3a7527 was a3a7527, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 13:04:02

Attempting to add variable so that in C all constants start with RTEMS_
and all directives start with rtems_.

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