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 | |
---|
27 | The signal manager provides the capabilities required |
---|
28 | for asynchronous communication. The directives provided by the |
---|
29 | signal 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 | |
---|
54 | The signal manager allows a task to optionally define |
---|
55 | an asynchronous signal routine (ASR). An ASR is to a task what |
---|
56 | an ISR is to an application's set of tasks. When the processor |
---|
57 | is interrupted, the execution of an application is also |
---|
58 | interrupted and an ISR is given control. Similarly, when a |
---|
59 | signal 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 |
---|
61 | effect on the receiving task's current execution state. |
---|
62 | |
---|
63 | A signal flag is used by a task (or ISR) to inform |
---|
64 | another task of the occurrence of a significant situation. |
---|
65 | Thirty-two signal flags are associated with each task. A |
---|
66 | collection of one or more signals is referred to as a signal |
---|
67 | set. A signal set is posted when it is directed (or sent) to a |
---|
68 | task. A pending signal is a signal that has been sent to a task |
---|
69 | with 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 | |
---|
77 | The format of an ASR is similar to that of an ISR |
---|
78 | with the following exceptions: |
---|
79 | |
---|
80 | @itemize @bullet |
---|
81 | @item ISRs are scheduled by the processor hardware. ASRs are |
---|
82 | scheduled by RTEMS. |
---|
83 | |
---|
84 | @item ISRs do not execute in the context of a task and may |
---|
85 | invoke only a subset of directives. ASRs execute in the context |
---|
86 | of a task and may execute any directive. |
---|
87 | |
---|
88 | @item When an ISR is invoked, it is passed the vector number |
---|
89 | as its argument. When an ASR is invoked, it is passed the |
---|
90 | signal set as its argument. |
---|
91 | |
---|
92 | @item An ASR has a task mode which can be different from that |
---|
93 | of the task. An ISR does not execute as a task and, as a |
---|
94 | result, 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 | |
---|
102 | A signal set is built by a bitwise OR of the desired |
---|
103 | signals. The set of valid signals is @code{SIGNAL_0} through |
---|
104 | @code{SIGNAL_31}. If a signal is not explicitly specified in the |
---|
105 | signal set, then it is not present. Signal values are |
---|
106 | specifically designed to be mutually exclusive, therefore |
---|
107 | bitwise OR and addition operations are equivalent as long as |
---|
108 | each signal appears exactly once in the component list. |
---|
109 | |
---|
110 | This example demonstrates the signal parameter used |
---|
111 | when sending the signal set consisting of |
---|
112 | @code{SIGNAL_6}, @code{SIGNAL_15}, and @code{SIGNAL_31}. |
---|
113 | The 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 | |
---|
122 | In general, an ASR's mode is built by a bitwise OR of |
---|
123 | the desired mode components. The set of valid mode components |
---|
124 | is the same as those allowed with the task_create and task_mode |
---|
125 | directives. A complete list of mode options is provided in the |
---|
126 | following 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 | |
---|
154 | Mode values are specifically designed to be mutually |
---|
155 | exclusive, therefore bitwise OR and addition operations are |
---|
156 | equivalent as long as each mode appears exactly once in the |
---|
157 | component list. A mode component listed as a default is not |
---|
158 | required to appear in the mode list, although it is a good |
---|
159 | programming practice to specify default components. If all |
---|
160 | defaults are desired, the mode DEFAULT_MODES should be specified |
---|
161 | on this call. |
---|
162 | |
---|
163 | This example demonstrates the mode parameter used |
---|
164 | with the signal_catch to establish an ASR which executes at |
---|
165 | interrupt level three and is non-preemptible. The mode should |
---|
166 | be set to |
---|
167 | @code{@value{RPREFIX}INTERRUPT_LEVEL(3) @value{OR} @value{RPREFIX}NO_PREEMPT} |
---|
168 | to indicate the |
---|
169 | desired 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 | |
---|
188 | The signal_catch directive establishes an ASR for the |
---|
189 | calling task. The address of the ASR and its execution mode are |
---|
190 | specified to this directive. The ASR's mode is distinct from |
---|
191 | the task's mode. For example, the task may allow preemption, |
---|
192 | while that task's ASR may have preemption disabled. Until a |
---|
193 | task calls signal_catch the first time, its ASR is invalid, and |
---|
194 | no signal sets can be sent to the task. |
---|
195 | |
---|
196 | A task may invalidate its ASR and discard all pending |
---|
197 | signals by calling signal_catch with a value of NULL for the |
---|
198 | ASR's address. When a task's ASR is invalid, new signal sets |
---|
199 | sent to this task are discarded. |
---|
200 | |
---|
201 | A task may disable ASR processing (NO_ASR) via the |
---|
202 | task_mode directive. When a task's ASR is disabled, the signals |
---|
203 | sent to it are left pending to be processed later when the ASR |
---|
204 | is enabled. |
---|
205 | |
---|
206 | Any directive that can be called from a task can also |
---|
207 | be called from an ASR. A task is only allowed one active ASR. |
---|
208 | Thus, each call to signal_catch replaces the previous one. |
---|
209 | |
---|
210 | Normally, signal processing is disabled for the ASR's |
---|
211 | execution mode, but if signal processing is enabled for the ASR, |
---|
212 | the 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 | |
---|
219 | The signal_send directive allows both tasks and ISRs |
---|
220 | to send signals to a target task. The target task and a set of |
---|
221 | signals are specified to the signal_send directive. The sending |
---|
222 | of a signal to a task has no effect on the execution state of |
---|
223 | that task. If the task is not the currently running task, then |
---|
224 | the signals are left pending and processed by the task's ASR the |
---|
225 | next time the task is dispatched to run. The ASR is executed |
---|
226 | immediately before the task is dispatched. If the currently |
---|
227 | running task sends a signal to itself or is sent a signal from |
---|
228 | an ISR, its ASR is immediately dispatched to run provided signal |
---|
229 | processing is enabled. |
---|
230 | |
---|
231 | If an ASR with signals enabled is preempted by |
---|
232 | another task or an ISR and a new signal set is sent, then a new |
---|
233 | copy of the ASR will be invoked, nesting the preempted ASR. |
---|
234 | Upon completion of processing the new signal set, control will |
---|
235 | return to the preempted ASR. In this situation, the ASR must be |
---|
236 | reentrant. |
---|
237 | |
---|
238 | Like events, identical signals sent to a task are not |
---|
239 | queued. In other words, sending the same signal multiple times |
---|
240 | to a task (without any intermediate signal processing occurring |
---|
241 | for the task), has the same result as sending that signal to |
---|
242 | that 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 | |
---|
249 | Asynchronous signals were designed to provide the |
---|
250 | capability to generate software interrupts. The processing of |
---|
251 | software interrupts parallels that of hardware interrupts. As a |
---|
252 | result, the differences between the formats of ASRs and ISRs is |
---|
253 | limited to the meaning of the single argument passed to an ASR. |
---|
254 | The ASR should have the following calling sequence and adhere to |
---|
255 | @value{LANGUAGE} calling conventions: |
---|
256 | |
---|
257 | @ifset is-C |
---|
258 | @example |
---|
259 | rtems_asr user_routine( |
---|
260 | rtems_signal_set signals |
---|
261 | ); |
---|
262 | @end example |
---|
263 | @end ifset |
---|
264 | |
---|
265 | @ifset is-Ada |
---|
266 | @example |
---|
267 | procedure User_Routine ( |
---|
268 | Signals : in RTEMS.Signal_Set |
---|
269 | ); |
---|
270 | @end example |
---|
271 | @end ifset |
---|
272 | |
---|
273 | When the ASR returns to RTEMS the mode and execution |
---|
274 | path of the interrupted task (or ASR) is restored to the context |
---|
275 | prior 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 | |
---|
288 | This section details the signal manager's directives. |
---|
289 | A subsection is dedicated to each of this manager's directives |
---|
290 | and describes the calling sequence, related constants, usage, |
---|
291 | and 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 |
---|
303 | rtems_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 |
---|
312 | procedure 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 | |
---|
325 | This directive establishes an asynchronous signal |
---|
326 | routine (ASR) for the calling task. The asr_handler parameter |
---|
327 | specifies the entry point of the ASR. If asr_handler is NULL, |
---|
328 | the ASR for the calling task is invalidated and all pending |
---|
329 | signals are cleared. Any signals sent to a task with an invalid |
---|
330 | ASR are discarded. The mode parameter specifies the execution |
---|
331 | mode for the ASR. This execution mode supersedes the task's |
---|
332 | execution mode while the ASR is executing. |
---|
333 | |
---|
334 | @subheading NOTES: |
---|
335 | |
---|
336 | This directive will not cause the calling task to be |
---|
337 | preempted. |
---|
338 | |
---|
339 | The 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 |
---|
377 | rtems_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 |
---|
386 | procedure 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 | |
---|
401 | This directive sends a signal set to the task |
---|
402 | specified in id. The signal_set parameter contains the signal |
---|
403 | set to be sent to the task. |
---|
404 | |
---|
405 | If a caller sends a signal set to a task with an |
---|
406 | invalid ASR, then an error code is returned to the caller. If a |
---|
407 | caller sends a signal set to a task whose ASR is valid but |
---|
408 | disabled, then the signal set will be caught and left pending |
---|
409 | for the ASR to process when it is enabled. If a caller sends a |
---|
410 | signal set to a task with an ASR that is both valid and enabled, |
---|
411 | then the signal set is caught and the ASR will execute the next |
---|
412 | time the task is dispatched to run. |
---|
413 | |
---|
414 | @subheading NOTES: |
---|
415 | |
---|
416 | Sending a signal set to a task has no effect on that |
---|
417 | task's state. If a signal set is sent to a blocked task, then |
---|
418 | the task will remain blocked and the signals will be processed |
---|
419 | when the task becomes the running task. |
---|
420 | |
---|
421 | Sending a signal set to a global task which does not |
---|
422 | reside on the local node will generate a request telling the |
---|
423 | remote node to send the signal set to the specified task. |
---|
424 | |
---|