source: rtems/doc/itron3.0/tasksync.t @ 3135649

4.104.114.84.95
Last change on this file since 3135649 was 56634c5, checked in by Joel Sherrill <joel.sherrill@…>, on 07/13/99 at 18:05:13

Update from Jeff Mayes, Jennifer Averett, and Suzie Provitt.

  • Property mode set to 100644
File size: 18.3 KB
Line 
1@c
2@c  This is the chapter from the RTEMS ITRON User's Guide that
3@c  documents the services provided by the task-dependent synchronization
4@c  manager.
5@c
6@c  $Id$
7@c
8
9@chapter Task-Dependent Synchronization Manager
10
11@section Introduction
12
13The task-dependent synchronization manager is designed to utilize those synchronization
14functions already supported by tasks.  This includes functions that suspend tasks for a while and associated functions that release SUSPEND state, and synchronization functions which make tasks wait and wake them up.
15
16The services provided by the task-dependent synchronization manager are:
17
18@itemize @bullet
19@item @code{sus_tsk} - Suspend Other Task
20@item @code{rsm_tsk} - Resume Suspended Task
21@item @code{frsm_tsk} - Forcibly Resume Suspended Task
22@item @code{slp_tsk} - Sleep Task
23@item @code{tslp_tsk} - Sleep Task with Timeout
24@item @code{wup_tsk} - Wakeup Other Task
25@item @code{can_wup} - Cancel Wakeup Request
26@end itemize
27
28@section Operations
29@subsection Suspend Other Task
30This call stops the execution of a task by putting it into a SUSPEND state.  This call is not able to specify itself, since this would end the flow of execution altogether.  If the task is already in a WAIT state, then SUSPEND is added to become WAIT-SUSPEND.  These modes are turned on and off separately, without affecting one another.  Furthermore, SUSPEND states can be nested, and tasks in a SUSPEND state are allocated resources as normal.
31
32@subsection Resume Suspended Task
33This operation restarts the execution of a task that was previously stopped by the SUSPEND OTHER TASK call.  Obviously, a task cannot specify itself using this call.  Since SUSPEND states can be nested, one call to RESUME releases only one SUSPEND.  Thus, it takes as many RESUMES as SUSPENDS to return the task to execution.
34
35@subsection Forcibly Resume Suspended Task
36This call has the same functionality as the previously mentioned Resume Suspended Task with one exception.  This call releases all nested SUSPENDS at once, which guarantees the task will return to execution.
37
38@subsection Sleep Task
39The Sleep Task operation causes the specified task to sleep until a Wakeup Task function is called.  This puts the task in a WAIT state.  WAIT states can not be nested, but can be combined with SUSPEND states as mentioned earlier. 
40
41@subsection Sleep Task with Timeout
42This function is identical to the Sleep Task function with an added timeout attribute.  If the timeout mark is reached before a Wakeup call is recieved, an error is generated.
43
44@subsection Wakeup Other Task
45The Wakeup Other Task call is used to release the WAIT state of a task.  These calls can be previously queued using the wupcnt value so that when the matching Sleep Task is executed, there will be no delay.
46
47@subsection Cancel Wakeup Request
48This function call resets the value of wupcnt to zero, thereby canceling all associated wakeup requests.  A call to self is acceptable for this operation, and may even be useful for monitoring certain situations.
49
50@section System Calls
51
52This section details the task-dependent synchronization manager's services. A subsection is dedicated to each of this manager's services and describes the calling sequence, related constants, usage, and status codes.
53
54
55@c
56@c  sus_tsk
57@c
58
59@page
60@subsection sus_tsk - Suspend Other Task
61
62@subheading CALLING SEQUENCE:
63
64@ifset is-C
65@example
66ER sus_tsk(
67  ID tskid
68);
69@end example
70@end ifset
71
72@ifset is-Ada
73@end ifset
74
75@subheading STATUS CODES:
76
77@code{E_OK} - Normal Completion
78
79@code{E_ID} - Invalid ID Number (tskid was invalid or could not be used)
80
81@code{E_NOEXS} - Object does not exist (the task specified by tskid does not exist)
82
83@code{E_OACV} - Object access violation (A tskid less than -4 was specified from a user task.  This is implementation dependent.)
84
85@code{E_OBJ} - Invalid object state (the specified task is in DORMANT state or the issuing task specified itself)
86
87@code{E_QOVR} - Queuing or nesting overflow (the number of nesting levels given by suscnt went over the maximum allowed)
88
89@code{EN_OBJNO} - An object number which could not be accessed on the target node is specified.
90
91@code{EN_CTXID} - Specified an object on another node when the system call was issued from a task in dispatch disabled state or from a task-independent portion
92
93@subheading DESCRIPTION:
94This system call suspends the execution of the task specified by tskid by putting it into SUSPEND state.
95
96SUSPEND state is released by issuing the rsm_tsk or frsm_tsk system call. If the task specified to sus_tsk is already in WAIT state, it will be put in the combined WAIT-SUSPEND state by the execution of sus_tsk.  If wait conditions for the task are later fulfilled, it will enter SUSPEND state. If rsm_tsk is issued on the task, it will return to the WAIT state before the suspension.
97
98Since SUSPEND state indicates the suspension of execution by a system call issued from another task, a task may not specify itself to this system call. An E_OBJ error will result if a task specifies itself.
99
100If more than one sus_tsk call is issued to a task, that task will be put in multiple SUSPEND states.  This is called suspend request nesting.  When this is done, rsm_tsk must be issued the same number of times which sus_tsk was issued (suscnt) in order to return the task to its original state before the suspension.  This means it is possible to nest the pairs of sus_tsk and rsm_tsk.
101
102The maximum number of times suspend requests may be nested, and even whether or not suspend request nesting (the ability to issue sus_tsk on the same task more than once) is even allowed, is implementation dependent.  Suspend request nesting is considered an extended function [level X] for which compatibility and connectivity are not guaranteed.
103
104An E_QOVR error will result if sus_tsk is issued more than once on the same task on a system which does not support suspend request nesting or if it is issued more than the maximum number of times allowed.
105
106@subheading NOTES:
107A task which is suspended in addition to waiting for resources (such as waiting for a semaphore) can be allocated resources (such as semaphore counts) based on the same conditions as tasks which are not suspended.  Even when suspended, the allocation of resources is not delayed in any way.  Conditions concerning resource allocation and release of the wait state remain unchanged. In other words, SUSPEND state is completely independent of other processing and task states.  If it is desirable to delay the allocation of resources to a task which is suspended, the user should use chg_pri in conjunction with sus_tsk and rsm_tsk.
108
109@c
110@c  rsm_tsk
111@c
112
113@page
114@subsection rsm_tsk - Resume Suspended Task
115
116@subheading CALLING SEQUENCE:
117
118@ifset is-C
119@example
120ER rsm_tsk(
121  ID tskid
122);
123@end example
124@end ifset
125
126@ifset is-Ada
127@end ifset
128
129@subheading STATUS CODES:
130
131@code{E_OK} - Normal Completion
132
133@code{E_ID} - Invalid ID Number (tskid was invalid or could not be used)
134
135@code{E_NOEXS} - Object does not exist (the task specified by tskid does not exist)
136
137@code{E_OACV} - Object access violation (A tskid less than -4 was specified from a user task.  This is implementation dependent.)
138
139@code{E_OBJ} - Invalid object state (the target task is not in SUSPEND state (including when it is DORMANT or when the issuing task specifies itself))
140
141@code{EN_OBJNO} - An object number which could not be accessed on the target node is specified.
142
143@code{EN_CTXID} - Specified an object on another node when the system call was issued from a task in dispatch disabled state or from a task-independent portion
144
145@subheading DESCRIPTION:
146This system call releases SUSPEND state of the task specified by tskid.  Specifically, it causes SUSPEND state to be released and the execution of the specified task to resume when the task has been suspended by the prior execution of sus_tsk.
147If the specified task is in WAIT-SUSPEND state, the execution of rsm_tsk only releases the SUSPEND state, and the task will become WAIT state.
148
149A task cannot specify itself to this system call.  An E_OBJ error will result if a task specifies itself.
150
151Rsm_tsk only releases one suspend request from the suspend request nest (suscnt).  Accordingly, if more than one sus_tsk has been issued on the task in question (suscnt >= 2), that task will remain suspended even after the execution of rsm_tsk is completed.
152
153@subheading NOTES:
154It is implementation dependent which location in the ready queue a task returns to after the task which has been suspended from RUN or READY state is resumed by rsm_tsk.
155
156@c
157@c  frsm_tsk
158@c
159
160@page
161@subsection frsm_tsk - Forcibly Resume Suspended Task
162
163@subheading CALLING SEQUENCE:
164
165@ifset is-C
166@example
167ER ercd =frsm_tsk(
168  ID tskid
169);
170@end example
171@end ifset
172
173@ifset is-Ada
174@end ifset
175
176@subheading STATUS CODES:
177
178@code{E_OK} - Normal Completion
179
180@code{E_ID} - Invalid ID Number (tskid was invalid or could not be used)
181
182@code{E_NOEXS} - Object does not exist (the task specified by tskid does not exist)
183
184@code{E_OACV} - Object access violation (A tskid less than -4 was specified from a user task.  This is implementation dependent.)
185
186@code{E_OBJ} - Invalid object state (the target task is not in SUSPEND state (including when it is DORMANT or when the issuing task specifies itself))
187
188@code{EN_OBJNO} - An object number which could not be accessed on the target node is specified.
189
190@code{EN_CTXID} - Specified an object on another node when the system call was issued from a task in dispatch disabled state or from a task-independent portion
191
192@subheading DESCRIPTION:
193This system call releases SUSPEND state of the task specified by tskid.  Specifically, it causes SUSPEND state to be released and the execution of the specified task to resume when the task has been suspended by the prior execution of sus_tsk.  If the specified task is in WAIT-SUSPEND state, the execution of rsm_tsk only releases the SUSPEND state, and the task will become WAIT state.
194
195A task cannot specify itself to this system call.  An E_OBJ error will result if a task specifies itself.
196
197Frsm_tsk will clear all suspend requests (suscnt = 0) even if more than one sus_tsk has been issued (suscnt >= 2) on the same task.  In other words, SUSPEND state is guaranteed to be released, and execution will resume unless the task in question had been in combined WAIT-SUSPEND state.
198
199@subheading NOTES:
200It is implementation dependent which location in the ready queue a task returns to after the task which has been suspended from RUN or READY state is resumed by frsm_tsk.
201
202
203@c
204@c  slp_tsk
205@c
206
207@page
208@subsection slp_tsk - Sleep Task Sleep Task with Timeout
209
210@subheading CALLING SEQUENCE:
211
212@ifset is-C
213@example
214ER slp_tsk( void );
215@end example
216@end ifset
217
218@ifset is-Ada
219@end ifset
220
221@subheading STATUS CODES:
222
223@code{E_OK} - Normal Completion
224
225@code{E_PAR} - Parameter error (a timeout value -2 or less was specified)
226
227@code{E_RLWAI} - WAIT state was forcibly released (rel_wai was received while waiting) 
228
229@code{E_TMOUT} - Polling failure or timeout exceeded
230
231@code{E_CTX} - Context error (issued from task-independent portions or a task in dispatch disabled state)
232
233@subheading DESCRIPTION:
234
235This system call puts the issuing task (which was in RUN state) into WAIT state, causing the issuing task to sleep until wup_tsk is invoked.
236
237@subheading NOTES:
238Since the slp_tsk system call causes the issuing task to enter WAIT state, slp_tsk calls may not be nested.  It is possible, however, for another task to execute a sus_tsk on a task which has put itself in WAIT state using slp_tsk.  If this happens, the task will enter the combined WAIT-SUSPEND state.
239
240No polling function for slp_tsk is provided.  A similar function can be implemented if necessary using can_wup.
241
242@c
243@c  tslp_tsk
244@c
245
246@page
247@subsection tslp_tsk - Sleep Task with Timeout
248
249@subheading CALLING SEQUENCE:
250
251@ifset is-C
252@example
253ER ercd =tslp_tsk(
254  TMO tmout
255);
256@end example
257@end ifset
258
259@ifset is-Ada
260@end ifset
261
262@subheading STATUS CODES:
263
264@code{E_OK} - Normal Completion
265
266@code{E_PAR} - Parameter error (a timeout value -2 or less was specified)
267
268@code{E_RLWAI} - WAIT state was forcibly released (rel_wai was received while waiting) 
269
270@code{E_TMOUT} - Polling failure or timeout exceeded
271
272@code{E_CTX} - Context error (issued from task-independent portions or a task in dispatch disabled state)
273
274@subheading DESCRIPTION:
275The tslp_tsk system call is the same as slp_tsk but with an additional timeout feature.  If a wup_tsk is issued before the period of time specified by tmout elapses, tslp_tsk will complete normally.  An E_TMOUT error will result if no wup_tsk is issued before the time specified by tmout expires.  Specifying tmout = TMO_FEVR = -1 can be used to set the timeout period to forever (no timeout).  In this case, tslp_tsk will function exactly the same as slp_tsk causing the issuing task to wait forever for wup_tsk to be issued.
276
277@subheading NOTES:
278Since the tslp_tsk system call causes the issuing task to enter WAIT state, tslp_tsk calls may not be nested.  It is possible, however, for another task to execute a sus_tsk on a task which has put itself in WAIT state using tslp_tsk.  If this happens, the task will enter the combined WAIT-SUSPEND state.
279
280If you simply wish to delay a task (make it wait for a while), use dly_tsk rather than tslp_tsk.
281
282@c
283@c  wup_tsk
284@c
285
286@page
287@subsection wup_tsk - Wakeup Other Task
288
289@subheading CALLING SEQUENCE:
290
291@ifset is-C
292@example
293ER wup_tsk(
294  ID tskid
295);
296@end example
297@end ifset
298
299@ifset is-Ada
300@end ifset
301
302@subheading STATUS CODES:
303
304@code{E_OK} - Normal Completion
305
306@code{E_ID} - Invalid ID Number (tskid was invalid or could not be used)
307
308@code{E_NOEXS} - Object does not exist (the task specified by tskid does not exist)
309
310@code{E_OACV} - Object access violation (A tskid less than -4 was specified from a user task.  This is implementation dependent.)
311
312@code{E_OBJ} - Invalid object state (the specified task is in DORMANT state or the issuing task specified itself)
313
314@code{E_QOVR} - Queuing or nesting overflow (wakeup request queuing count will exceed the maximum value allowed for wupcnt)
315
316@code{EN_OBJNO} - An object number which could not be accessed on the target node is specified.
317
318@code{EN_CTXID} - Specified an object on another node when the system call was issued from a task in dispatch disabled state or from a task-independent portion
319
320@subheading DESCRIPTION:
321This system call releases the WAIT state of the task specified by tskid caused by the execution of slp_tsk or tslp_tsk.
322
323A task cannot specify itself in this system call.  An E_OBJ error will result if a task specifies itself.
324
325If the specified task is not in the WAIT state caused by a slp_tsk or tslp_tsk, the wakeup request based on the wup_tsk call will be queued. In other words, a record will be kept that a wup_tsk has been issued for the specified task and no WAIT state will result even if slp_tsk or tslp_tsk is executed by the task later.  This is called queuing for wakeup request.
326
327@subheading NOTES:
328Wakeup requests are queued as follows.  A wakeup request queuing count (wupcnt) is kept in the TCB for each task.  Initially (when sta_tsk is executed) the value of wupcnt is 0.  Executing wup_tsk on a task which is not waiting for a wakeup increments the wakeup request queuing count by one for the specified task.  If slp_tsk or tslp_tsk is executed on that task, its wakeup request queuing count will be decremented by one.  If the task with wakeup request queuing count = 0 executes slp_tsk or tslp_tsk, that task will be put in WAIT state rather than decrementing the wakeup request queuing count.
329
330It is always possible to queue at least one wup_tsk (wupcnt = 1); the maximum allowable number for the wakeup request queuing count (wupcnt) is implementation dependent, and may be any number higher than or equal to one. In other words, while the first wup_tsk issued to a task which is not waiting for a wakeup will not result in an error, it is implementation dependent whether or not any further wup_tsk calls on the same task will result in an error.  The ability to queue more than one wakeup request is considered an extended function [level X] for which compatibility and connectivity are not guaranteed.
331
332An E_QOVR error will result if wup_tsk is issued more than the maximum value allowed for the wakeup request queuing count (wupcnt).
333
334
335@c
336@c  can_wup
337@c
338
339@page
340@subsection can_wup - Cancel Wakeup Request
341
342@subheading CALLING SEQUENCE:
343
344@ifset is-C
345@example
346ER can_wup(
347  INT *p_wupcnt,
348  ID tskid
349);
350@end example
351@end ifset
352
353@ifset is-Ada
354@end ifset
355
356@subheading STATUS CODES:
357
358@code{E_OK} - Normal Completion
359
360@code{E_ID} - Invalid ID Number (tskid was invalid or could not be used)
361
362@code{E_NOEXS} - Object does not exist (the task specified by tskid does not exist)
363
364@code{E_OACV} - Object access violation (A tskid less than -4 was specified from a user task.  This is implementation dependent.)
365
366@code{E_OBJ} - Invalid object state (the target task is in DORMANT state)
367
368@code{EN_OBJNO} - An object number which could not be accessed on the target node is specified.
369
370@code{EN_CTXID} - Specified an object on another node when the system call was issued from a task in dispatch disabled state or from a task-independent portion
371
372@code{EN_RPAR} - A value outside the range supported by the issuing node and/or transmission packet format was returned as a return parameter (a value outside supported range was returned for wupcnt)
373
374@subheading DESCRIPTION:
375This system call returns the wakeup request queuing count (wupcnt) for the task specified by tskid while canceling all associated wakeup requests. Specifically, it resets the wakeup request queuing count (wupcnt) to 0.
376
377A task may specify itself by specifying tskid = TSK_SELF = 0.  Note, however, that an E_ID error will result if tskid = TSK_SELF = 0 is specified when this system call is issued from a task-independent portion.
378
379@subheading NOTES:
380An EN_RPAR error will result if the number of bits used on the target node is larger than that used on the requesting node, and if a value not supported by the requesting node is returned for wupcnt.
381
382This system call can be used to determine whether or not processing has ended within a certain period when a task should periodically waken up by wup_tsk and do some processing.  In other words, if a task monitoring the progress of its processing issues can_wup before issuing a slp_tsk after finishing processing associated with a previous wakeup request, and if wupcnt, one of can_wup's return parameters, is equal to or greater than one, it indicates that the processing for the previous wakeup request does not complete within a required time.  This allows the monitoring task to take actions against processing delays.
383
384
Note: See TracBrowser for help on using the repository browser.