[ae68ff0] | 1 | @c |
---|
[0660b4f8] | 2 | @c COPYRIGHT (c) 1988-1999. |
---|
[ae68ff0] | 3 | @c On-Line Applications Research Corporation (OAR). |
---|
| 4 | @c All rights reserved. |
---|
| 5 | @c |
---|
[139b2e4a] | 6 | @c $Id$ |
---|
| 7 | @c |
---|
[ae68ff0] | 8 | |
---|
| 9 | @chapter Task Manager |
---|
| 10 | |
---|
[169502e] | 11 | @cindex tasks |
---|
| 12 | |
---|
[ae68ff0] | 13 | @section Introduction |
---|
| 14 | |
---|
| 15 | The task manager provides a comprehensive set of directives to |
---|
| 16 | create, delete, and administer tasks. The directives provided |
---|
| 17 | by the task manager are: |
---|
| 18 | |
---|
| 19 | @itemize @bullet |
---|
[f331481c] | 20 | @item @code{@value{DIRPREFIX}task_create} - Create a task |
---|
| 21 | @item @code{@value{DIRPREFIX}task_ident} - Get ID of a task |
---|
| 22 | @item @code{@value{DIRPREFIX}task_start} - Start a task |
---|
| 23 | @item @code{@value{DIRPREFIX}task_restart} - Restart a task |
---|
| 24 | @item @code{@value{DIRPREFIX}task_delete} - Delete a task |
---|
| 25 | @item @code{@value{DIRPREFIX}task_suspend} - Suspend a task |
---|
| 26 | @item @code{@value{DIRPREFIX}task_resume} - Resume a task |
---|
[5ad8673] | 27 | @item @code{@value{DIRPREFIX}task_is_suspended} - Determine if a task is Suspended |
---|
[f331481c] | 28 | @item @code{@value{DIRPREFIX}task_set_priority} - Set task priority |
---|
| 29 | @item @code{@value{DIRPREFIX}task_mode} - Change current task's mode |
---|
| 30 | @item @code{@value{DIRPREFIX}task_get_note} - Get task notepad entry |
---|
| 31 | @item @code{@value{DIRPREFIX}task_set_note} - Set task notepad entry |
---|
| 32 | @item @code{@value{DIRPREFIX}task_wake_after} - Wake up after interval |
---|
| 33 | @item @code{@value{DIRPREFIX}task_wake_when} - Wake up when specified |
---|
[dc2b337] | 34 | @item @code{@value{DIRPREFIX}task_variable_add} - Associate per task variable |
---|
| 35 | @item @code{@value{DIRPREFIX}task_variable_delete} - Remove per task variable |
---|
[ae68ff0] | 36 | @end itemize |
---|
| 37 | |
---|
| 38 | @section Background |
---|
| 39 | |
---|
| 40 | @subsection Task Definition |
---|
| 41 | |
---|
[169502e] | 42 | @cindex task, definition |
---|
| 43 | |
---|
[75e22db] | 44 | Many definitions of a task have been proposed in computer literature. |
---|
| 45 | Unfortunately, none of these definitions encompasses all facets of the |
---|
| 46 | concept in a manner which is operating system independent. Several of the |
---|
| 47 | more common definitions are provided to enable each user to select a |
---|
| 48 | definition which best matches their own experience and understanding of the |
---|
| 49 | task concept: |
---|
[ae68ff0] | 50 | |
---|
| 51 | @itemize @bullet |
---|
| 52 | @item a "dispatchable" unit. |
---|
| 53 | |
---|
| 54 | @item an entity to which the processor is allocated. |
---|
| 55 | |
---|
| 56 | @item an atomic unit of a real-time, multiprocessor system. |
---|
| 57 | |
---|
| 58 | @item single threads of execution which concurrently compete for resources. |
---|
| 59 | |
---|
| 60 | @item a sequence of closely related computations which can execute |
---|
| 61 | concurrently with other computational sequences. |
---|
| 62 | |
---|
| 63 | @end itemize |
---|
| 64 | |
---|
| 65 | From RTEMS' perspective, a task is the smallest thread of |
---|
| 66 | execution which can compete on its own for system resources. A |
---|
| 67 | task is manifested by the existence of a task control block |
---|
| 68 | (TCB). |
---|
| 69 | |
---|
| 70 | @subsection Task Control Block |
---|
| 71 | |
---|
| 72 | The Task Control Block (TCB) is an RTEMS defined data structure |
---|
| 73 | which contains all the information that is pertinent to the |
---|
| 74 | execution of a task. During system initialization, RTEMS |
---|
| 75 | reserves a TCB for each task configured. A TCB is allocated |
---|
| 76 | upon creation of the task and is returned to the TCB free list |
---|
| 77 | upon deletion of the task. |
---|
| 78 | |
---|
| 79 | The TCB's elements are modified as a result of system calls made |
---|
| 80 | by the application in response to external and internal stimuli. |
---|
| 81 | TCBs are the only RTEMS internal data structure that can be |
---|
| 82 | accessed by an application via user extension routines. The TCB |
---|
| 83 | contains a task's name, ID, current priority, current and |
---|
| 84 | starting states, execution mode, set of notepad locations, TCB |
---|
| 85 | user extension pointer, scheduling control structures, as well |
---|
| 86 | as data required by a blocked task. |
---|
| 87 | |
---|
| 88 | A task's context is stored in the TCB when a task switch occurs. |
---|
| 89 | When the task regains control of the processor, its context is |
---|
| 90 | restored from the TCB. When a task is restarted, the initial |
---|
| 91 | state of the task is restored from the starting context area in |
---|
| 92 | the task's TCB. |
---|
| 93 | |
---|
| 94 | @subsection Task States |
---|
| 95 | |
---|
[169502e] | 96 | @cindex task states |
---|
| 97 | |
---|
[ae68ff0] | 98 | A task may exist in one of the following five states: |
---|
| 99 | |
---|
| 100 | @itemize @bullet |
---|
[a3a7527] | 101 | @item @b{executing} - Currently scheduled to the CPU |
---|
| 102 | @item @b{ready} - May be scheduled to the CPU |
---|
| 103 | @item @b{blocked} - Unable to be scheduled to the CPU |
---|
| 104 | @item @b{dormant} - Created task that is not started |
---|
| 105 | @item @b{non-existent} - Uncreated or deleted task |
---|
[ae68ff0] | 106 | @end itemize |
---|
| 107 | |
---|
| 108 | An active task may occupy the executing, ready, blocked or |
---|
| 109 | dormant state, otherwise the task is considered non-existent. |
---|
| 110 | One or more tasks may be active in the system simultaneously. |
---|
| 111 | Multiple tasks communicate, synchronize, and compete for system |
---|
| 112 | resources with each other via system calls. The multiple tasks |
---|
| 113 | appear to execute in parallel, but actually each is dispatched |
---|
| 114 | to the CPU for periods of time determined by the RTEMS |
---|
| 115 | scheduling algorithm. The scheduling of a task is based on its |
---|
| 116 | current state and priority. |
---|
| 117 | |
---|
| 118 | @subsection Task Priority |
---|
| 119 | |
---|
[169502e] | 120 | @cindex task priority |
---|
| 121 | @cindex priority, task |
---|
| 122 | |
---|
[ae68ff0] | 123 | A task's priority determines its importance in relation to the |
---|
| 124 | other tasks executing on the same processor. RTEMS supports 255 |
---|
| 125 | levels of priority ranging from 1 to 255. Tasks of numerically |
---|
| 126 | smaller priority values are more important tasks than tasks of |
---|
| 127 | numerically larger priority values. For example, a task at |
---|
| 128 | priority level 5 is of higher privilege than a task at priority |
---|
| 129 | level 10. There is no limit to the number of tasks assigned to |
---|
| 130 | the same priority. |
---|
| 131 | |
---|
| 132 | Each task has a priority associated with it at all times. The |
---|
| 133 | initial value of this priority is assigned at task creation |
---|
| 134 | time. The priority of a task may be changed at any subsequent |
---|
| 135 | time. |
---|
| 136 | |
---|
| 137 | Priorities are used by the scheduler to determine which ready |
---|
| 138 | task will be allowed to execute. In general, the higher the |
---|
| 139 | logical priority of a task, the more likely it is to receive |
---|
| 140 | processor execution time. |
---|
| 141 | |
---|
| 142 | @subsection Task Mode |
---|
| 143 | |
---|
[169502e] | 144 | @cindex task mode |
---|
| 145 | |
---|
[ae68ff0] | 146 | A task's mode is a combination of the following four components: |
---|
| 147 | |
---|
| 148 | @itemize @bullet |
---|
| 149 | @item preemption |
---|
| 150 | @item ASR processing |
---|
| 151 | @item timeslicing |
---|
| 152 | @item interrupt level |
---|
| 153 | @end itemize |
---|
| 154 | |
---|
| 155 | It is used to modify RTEMS' scheduling process and to alter the |
---|
| 156 | execution environment of the task. |
---|
| 157 | |
---|
[169502e] | 158 | @cindex preemption |
---|
| 159 | |
---|
[75e22db] | 160 | The preemption component allows a task to determine when control of the |
---|
| 161 | processor is relinquished. If preemption is disabled |
---|
| 162 | (@code{@value{RPREFIX}NO_PREEMPT}), the task will retain control of the |
---|
| 163 | processor as long as it is in the executing state -- even if a higher |
---|
| 164 | priority task is made ready. If preemption is enabled |
---|
| 165 | (@code{@value{RPREFIX}PREEMPT}) and a higher priority task is made ready, |
---|
| 166 | then the processor will be taken away from the current task immediately and |
---|
| 167 | given to the higher priority task. |
---|
| 168 | |
---|
[169502e] | 169 | @cindex timeslicing |
---|
| 170 | |
---|
[75e22db] | 171 | The timeslicing component is used by the RTEMS scheduler to determine how |
---|
| 172 | the processor is allocated to tasks of equal priority. If timeslicing is |
---|
| 173 | enabled (@code{@value{RPREFIX}TIMESLICE}), then RTEMS will limit the amount |
---|
| 174 | of time the task can execute before the processor is allocated to another |
---|
| 175 | ready task of equal priority. The length of the timeslice is application |
---|
| 176 | dependent and specified in the Configuration Table. If timeslicing is |
---|
| 177 | disabled (@code{@value{RPREFIX}NO_TIMESLICE}), then the task will be |
---|
| 178 | allowed to execute until a task of higher priority is made ready. If |
---|
| 179 | @code{@value{RPREFIX}NO_PREEMPT} is selected, then the timeslicing |
---|
| 180 | component is ignored by the scheduler. |
---|
| 181 | |
---|
| 182 | The asynchronous signal processing component is used to determine when |
---|
| 183 | received signals are to be processed by the task. |
---|
| 184 | If signal processing is enabled (@code{@value{RPREFIX}ASR}), then signals |
---|
| 185 | sent to the task will be processed the next time the task executes. If |
---|
| 186 | signal processing is disabled (@code{@value{RPREFIX}NO_ASR}), then all |
---|
| 187 | signals received by the task will remain posted until signal processing is |
---|
| 188 | enabled. This component affects only tasks which have established a |
---|
| 189 | routine to process asynchronous signals. |
---|
[ae68ff0] | 190 | |
---|
[169502e] | 191 | @cindex interrupt level, task |
---|
| 192 | |
---|
[ae68ff0] | 193 | The interrupt level component is used to determine which |
---|
| 194 | interrupts will be enabled when the task is executing. |
---|
[f331481c] | 195 | @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} |
---|
| 196 | specifies that the task will execute at interrupt level n. |
---|
[ae68ff0] | 197 | |
---|
| 198 | @itemize @bullet |
---|
[f331481c] | 199 | @item @code{@value{RPREFIX}PREEMPT} - enable preemption (default) |
---|
| 200 | @item @code{@value{RPREFIX}NO_PREEMPT} - disable preemption |
---|
| 201 | @item @code{@value{RPREFIX}NO_TIMESLICE} - disable timeslicing (default) |
---|
| 202 | @item @code{@value{RPREFIX}TIMESLICE} - enable timeslicing |
---|
| 203 | @item @code{@value{RPREFIX}ASR} - enable ASR processing (default) |
---|
| 204 | @item @code{@value{RPREFIX}NO_ASR} - disable ASR processing |
---|
[a3a7527] | 205 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} - enable all interrupts (default) |
---|
| 206 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} - execute at interrupt level n |
---|
[ae68ff0] | 207 | @end itemize |
---|
| 208 | |
---|
| 209 | @subsection Accessing Task Arguments |
---|
| 210 | |
---|
[169502e] | 211 | @cindex task arguments |
---|
| 212 | |
---|
[ae68ff0] | 213 | All RTEMS tasks are invoked with a single argument which is |
---|
| 214 | specified when they are started or restarted. The argument is |
---|
| 215 | commonly used to communicate startup information to the task. |
---|
| 216 | The simplest manner in which to define a task which accesses it |
---|
| 217 | argument is: |
---|
| 218 | |
---|
[61389eac] | 219 | @ifset is-C |
---|
[ae68ff0] | 220 | @example |
---|
| 221 | rtems_task user_task( |
---|
| 222 | rtems_task_argument argument |
---|
| 223 | ); |
---|
| 224 | @end example |
---|
[61389eac] | 225 | @end ifset |
---|
| 226 | |
---|
| 227 | @ifset is-Ada |
---|
| 228 | @example |
---|
| 229 | procedure User_Task ( |
---|
| 230 | Argument : in RTEMS.Task_Argument_Ptr |
---|
| 231 | ); |
---|
| 232 | @end example |
---|
| 233 | @end ifset |
---|
[ae68ff0] | 234 | |
---|
| 235 | Application tasks requiring more information may view this |
---|
| 236 | single argument as an index into an array of parameter blocks. |
---|
| 237 | |
---|
| 238 | @subsection Floating Point Considerations |
---|
| 239 | |
---|
[169502e] | 240 | @cindex floating point |
---|
| 241 | |
---|
[75e22db] | 242 | Creating a task with the @code{@value{RPREFIX}FLOATING_POINT} flag results |
---|
| 243 | in additional memory being allocated for the TCB to store the state of the |
---|
| 244 | numeric coprocessor during task switches. This additional memory is |
---|
| 245 | @b{NOT} allocated for @code{@value{RPREFIX}NO_FLOATING_POINT} tasks. Saving |
---|
| 246 | and restoring the context of a @code{@value{RPREFIX}FLOATING_POINT} task |
---|
| 247 | takes longer than that of a @code{@value{RPREFIX}NO_FLOATING_POINT} task |
---|
| 248 | because of the relatively large amount of time required for the numeric |
---|
| 249 | coprocessor to save or restore its computational state. |
---|
| 250 | |
---|
| 251 | Since RTEMS was designed specifically for embedded military applications |
---|
| 252 | which are floating point intensive, the executive is optimized to avoid |
---|
| 253 | unnecessarily saving and restoring the state of the numeric coprocessor. |
---|
| 254 | The state of the numeric coprocessor is only saved when a |
---|
| 255 | @code{@value{RPREFIX}FLOATING_POINT} task is dispatched and that task was |
---|
| 256 | not the last task to utilize the coprocessor. In a system with only one |
---|
| 257 | @code{@value{RPREFIX}FLOATING_POINT} task, the state of the numeric |
---|
| 258 | coprocessor will never be saved or restored. |
---|
| 259 | |
---|
| 260 | Although the overhead imposed by @code{@value{RPREFIX}FLOATING_POINT} tasks |
---|
| 261 | is minimal, some applications may wish to completely avoid the overhead |
---|
| 262 | associated with @code{@value{RPREFIX}FLOATING_POINT} tasks and still |
---|
| 263 | utilize a numeric coprocessor. By preventing a task from being preempted |
---|
| 264 | while performing a sequence of floating point operations, a |
---|
| 265 | @code{@value{RPREFIX}NO_FLOATING_POINT} task can utilize the numeric |
---|
| 266 | coprocessor without incurring the overhead of a |
---|
| 267 | @code{@value{RPREFIX}FLOATING_POINT} context switch. This approach also |
---|
| 268 | avoids the allocation of a floating point context area. However, if this |
---|
| 269 | approach is taken by the application designer, NO tasks should be created |
---|
| 270 | as @code{@value{RPREFIX}FLOATING_POINT} tasks. Otherwise, the floating |
---|
| 271 | point context will not be correctly maintained because RTEMS assumes that |
---|
| 272 | the state of the numeric coprocessor will not be altered by |
---|
| 273 | @code{@value{RPREFIX}NO_FLOATING_POINT} tasks. |
---|
[ae68ff0] | 274 | |
---|
| 275 | If the supported processor type does not have hardware floating |
---|
[75e22db] | 276 | capabilities or a standard numeric coprocessor, RTEMS will not provide |
---|
| 277 | built-in support for hardware floating point on that processor. In this |
---|
| 278 | case, all tasks are considered @code{@value{RPREFIX}NO_FLOATING_POINT} |
---|
| 279 | whether created as @code{@value{RPREFIX}FLOATING_POINT} or |
---|
| 280 | @code{@value{RPREFIX}NO_FLOATING_POINT} tasks. A floating point emulation |
---|
| 281 | software library must be utilized for floating point operations. |
---|
| 282 | |
---|
| 283 | On some processors, it is possible to disable the floating point unit |
---|
| 284 | dynamically. If this capability is supported by the target processor, then |
---|
| 285 | RTEMS will utilize this capability to enable the floating point unit only |
---|
| 286 | for tasks which are created with the @code{@value{RPREFIX}FLOATING_POINT} |
---|
| 287 | attribute. The consequence of a @code{@value{RPREFIX}NO_FLOATING_POINT} |
---|
| 288 | task attempting to access the floating point unit is CPU dependent but will |
---|
| 289 | generally result in an exception condition. |
---|
[ae68ff0] | 290 | |
---|
[dc2b337] | 291 | @subsection Per Task Variables |
---|
| 292 | |
---|
| 293 | @cindex per task variables |
---|
| 294 | |
---|
| 295 | Per task variables are used to support global variables whose value |
---|
| 296 | may be unique to a task. After indicating that a variable should be |
---|
| 297 | treated as private or pre-task. The task can access and modify the |
---|
| 298 | variable, but the modifications will not appear to other tasks, and |
---|
| 299 | other tasks' modifications to that variable will not affect the value |
---|
| 300 | seen by the task. This is accomplished by saving and restoring the |
---|
| 301 | variable's value each time a task switch occurs to or from the calling task. |
---|
| 302 | |
---|
| 303 | This feature can be used when a routine is to be spawned repeatedly as |
---|
| 304 | several independent tasks. Although each task will have its own stack, |
---|
| 305 | and thus separate stack variables, they will all share the same static and |
---|
| 306 | global variables. To make a variable not shareable (i.e. a "global" variable |
---|
| 307 | that is specific to a single task), the tasks can call |
---|
| 308 | @code{rtems_task_variable_add} to make a separate copy of the variable |
---|
| 309 | for each task, but all at the same physical address. |
---|
| 310 | |
---|
| 311 | Task variables increase the context switch time to and from the |
---|
| 312 | tasks that own them so it is desirable to minimize the number of |
---|
| 313 | task variables. One efficient method is to have a single task |
---|
| 314 | variable that is a pointer to a dynamically allocated structure |
---|
| 315 | containing the task's private "global" data. |
---|
| 316 | |
---|
| 317 | A critical point with per-task variables is that each task must separately |
---|
| 318 | request that the same global variable is per-task private. |
---|
| 319 | |
---|
[ed11cadf] | 320 | @subsection Building a Task Attribute Set |
---|
[ae68ff0] | 321 | |
---|
[169502e] | 322 | @cindex task attributes, building |
---|
| 323 | |
---|
[ae68ff0] | 324 | In general, an attribute set is built by a bitwise OR of the |
---|
| 325 | desired components. The set of valid task attribute components |
---|
| 326 | is listed below: |
---|
| 327 | |
---|
| 328 | @itemize @bullet |
---|
[f331481c] | 329 | @item @code{@value{RPREFIX}NO_FLOATING_POINT} - does not use coprocessor (default) |
---|
| 330 | @item @code{@value{RPREFIX}FLOATING_POINT} - uses numeric coprocessor |
---|
| 331 | @item @code{@value{RPREFIX}LOCAL} - local task (default) |
---|
| 332 | @item @code{@value{RPREFIX}GLOBAL} - global task |
---|
[ae68ff0] | 333 | @end itemize |
---|
| 334 | |
---|
| 335 | Attribute values are specifically designed to be mutually |
---|
| 336 | exclusive, therefore bitwise OR and addition operations are |
---|
| 337 | equivalent as long as each attribute appears exactly once in the |
---|
| 338 | component list. A component listed as a default is not required |
---|
| 339 | to appear in the component list, although it is a good |
---|
| 340 | programming practice to specify default components. If all |
---|
[f331481c] | 341 | defaults are desired, then @code{@value{RPREFIX}DEFAULT_ATTRIBUTES} should be used. |
---|
[ae68ff0] | 342 | |
---|
| 343 | This example demonstrates the attribute_set parameter needed to |
---|
| 344 | create a local task which utilizes the numeric coprocessor. The |
---|
[f331481c] | 345 | attribute_set parameter could be @code{@value{RPREFIX}FLOATING_POINT} or |
---|
[a3a7527] | 346 | @code{@value{RPREFIX}LOCAL @value{OR} @value{RPREFIX}FLOATING_POINT}. |
---|
[a94c5a5d] | 347 | The attribute_set parameter can be set to |
---|
[f331481c] | 348 | @code{@value{RPREFIX}FLOATING_POINT} because @code{@value{RPREFIX}LOCAL} is the default for all created |
---|
[ae68ff0] | 349 | tasks. If the task were global and used the numeric |
---|
[a94c5a5d] | 350 | coprocessor, then the attribute_set parameter would be |
---|
[a3a7527] | 351 | @code{@value{RPREFIX}GLOBAL @value{OR} @value{RPREFIX}FLOATING_POINT}. |
---|
[ae68ff0] | 352 | |
---|
| 353 | @subsection Building a Mode and Mask |
---|
| 354 | |
---|
[169502e] | 355 | @cindex task mode, building |
---|
| 356 | |
---|
[ae68ff0] | 357 | In general, a mode and its corresponding mask is built by a |
---|
| 358 | bitwise OR of the desired components. The set of valid mode |
---|
| 359 | constants and each mode's corresponding mask constant is |
---|
| 360 | listed below: |
---|
| 361 | |
---|
| 362 | @ifset use-ascii |
---|
| 363 | @itemize @bullet |
---|
[f331481c] | 364 | @item @code{@value{RPREFIX}PREEMPT} is masked by |
---|
| 365 | @code{@value{RPREFIX}PREEMPT_MASK} and enables preemption |
---|
[a3a7527] | 366 | |
---|
[f331481c] | 367 | @item @code{@value{RPREFIX}NO_PREEMPT} is masked by |
---|
| 368 | @code{@value{RPREFIX}PREEMPT_MASK} and disables preemption |
---|
[a3a7527] | 369 | |
---|
[f331481c] | 370 | @item @code{@value{RPREFIX}NO_TIMESLICE} is masked by |
---|
| 371 | @code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing |
---|
[a3a7527] | 372 | |
---|
[f331481c] | 373 | @item @code{@value{RPREFIX}TIMESLICE} is masked by |
---|
| 374 | @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing |
---|
[a3a7527] | 375 | |
---|
[f331481c] | 376 | @item @code{@value{RPREFIX}ASR} is masked by |
---|
| 377 | @code{@value{RPREFIX}ASR_MASK} and enables ASR processing |
---|
[a3a7527] | 378 | |
---|
[f331481c] | 379 | @item @code{@value{RPREFIX}NO_ASR} is masked by |
---|
| 380 | @code{@value{RPREFIX}ASR_MASK} and disables ASR processing |
---|
[a3a7527] | 381 | |
---|
| 382 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} is masked by |
---|
[f331481c] | 383 | @code{@value{RPREFIX}INTERRUPT_MASK} and enables all interrupts |
---|
[a3a7527] | 384 | |
---|
[f331481c] | 385 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} is masked by |
---|
| 386 | @code{@value{RPREFIX}INTERRUPT_MASK} and sets interrupts level n |
---|
[ae68ff0] | 387 | @end itemize |
---|
| 388 | @end ifset |
---|
| 389 | |
---|
| 390 | @ifset use-tex |
---|
| 391 | @sp 1 |
---|
| 392 | @c this is temporary |
---|
| 393 | @itemize @bullet |
---|
[f331481c] | 394 | @item @code{@value{RPREFIX}PREEMPT} is masked by |
---|
| 395 | @code{@value{RPREFIX}PREEMPT_MASK} and enables preemption |
---|
[a3a7527] | 396 | |
---|
[f331481c] | 397 | @item @code{@value{RPREFIX}NO_PREEMPT} is masked by |
---|
| 398 | @code{@value{RPREFIX}PREEMPT_MASK} and disables preemption |
---|
[a3a7527] | 399 | |
---|
[f331481c] | 400 | @item @code{@value{RPREFIX}NO_TIMESLICE} is masked by |
---|
| 401 | @code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing |
---|
[a3a7527] | 402 | |
---|
[f331481c] | 403 | @item @code{@value{RPREFIX}TIMESLICE} is masked by |
---|
| 404 | @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing |
---|
[a3a7527] | 405 | |
---|
[f331481c] | 406 | @item @code{@value{RPREFIX}ASR} is masked by |
---|
| 407 | @code{@value{RPREFIX}ASR_MASK} and enables ASR processing |
---|
[a3a7527] | 408 | |
---|
[f331481c] | 409 | @item @code{@value{RPREFIX}NO_ASR} is masked by |
---|
| 410 | @code{@value{RPREFIX}ASR_MASK} and disables ASR processing |
---|
[a3a7527] | 411 | |
---|
| 412 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} is masked by |
---|
[f331481c] | 413 | @code{@value{RPREFIX}INTERRUPT_MASK} and enables all interrupts |
---|
[a3a7527] | 414 | |
---|
[f331481c] | 415 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} is masked by |
---|
| 416 | @code{@value{RPREFIX}INTERRUPT_MASK} and sets interrupts level n |
---|
[ae68ff0] | 417 | |
---|
| 418 | @end itemize |
---|
| 419 | |
---|
| 420 | @tex |
---|
| 421 | @end tex |
---|
| 422 | @end ifset |
---|
| 423 | |
---|
| 424 | @ifset use-html |
---|
| 425 | @html |
---|
| 426 | <CENTER> |
---|
| 427 | <TABLE COLS=3 WIDTH="80%" BORDER=2> |
---|
| 428 | <TR><TD ALIGN=center><STRONG>Mode Constant</STRONG></TD> |
---|
| 429 | <TD ALIGN=center><STRONG>Mask Constant</STRONG></TD> |
---|
| 430 | <TD ALIGN=center><STRONG>Description</STRONG></TD></TR> |
---|
[75e22db] | 431 | <TR><TD ALIGN=center>@value{RPREFIX}PREEMPT</TD> |
---|
| 432 | <TD ALIGN=center>@value{RPREFIX}PREEMPT_MASK</TD> |
---|
[ae68ff0] | 433 | <TD ALIGN=center>enables preemption</TD></TR> |
---|
[75e22db] | 434 | <TR><TD ALIGN=center>@value{RPREFIX}NO_PREEMPT</TD> |
---|
| 435 | <TD ALIGN=center>@value{RPREFIX}PREEMPT_MASK</TD> |
---|
[ae68ff0] | 436 | <TD ALIGN=center>disables preemption</TD></TR> |
---|
[75e22db] | 437 | <TR><TD ALIGN=center>@value{RPREFIX}NO_TIMESLICE</TD> |
---|
| 438 | <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD> |
---|
[ae68ff0] | 439 | <TD ALIGN=center>disables timeslicing</TD></TR> |
---|
[75e22db] | 440 | <TR><TD ALIGN=center>@value{RPREFIX}TIMESLICE</TD> |
---|
| 441 | <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD> |
---|
[ae68ff0] | 442 | <TD ALIGN=center>enables timeslicing</TD></TR> |
---|
[75e22db] | 443 | <TR><TD ALIGN=center>@value{RPREFIX}ASR</TD> |
---|
| 444 | <TD ALIGN=center>@value{RPREFIX}ASR_MASK</TD> |
---|
[ae68ff0] | 445 | <TD ALIGN=center>enables ASR processing</TD></TR> |
---|
[75e22db] | 446 | <TR><TD ALIGN=center>@value{RPREFIX}NO_ASR</TD> |
---|
| 447 | <TD ALIGN=center>@value{RPREFIX}ASR_MASK</TD> |
---|
[ae68ff0] | 448 | <TD ALIGN=center>disables ASR processing</TD></TR> |
---|
[75e22db] | 449 | <TR><TD ALIGN=center>@value{RPREFIX}INTERRUPT_LEVEL(0)</TD> |
---|
| 450 | <TD ALIGN=center>@value{RPREFIX}INTERRUPT_MASK</TD> |
---|
[ae68ff0] | 451 | <TD ALIGN=center>enables all interrupts</TD></TR> |
---|
[75e22db] | 452 | <TR><TD ALIGN=center>@value{RPREFIX}INTERRUPT_LEVEL(n)</TD> |
---|
| 453 | <TD ALIGN=center>@value{RPREFIX}INTERRUPT_MASK</TD> |
---|
[ae68ff0] | 454 | <TD ALIGN=center>sets interrupts level n</TD></TR> |
---|
| 455 | </TABLE> |
---|
| 456 | </CENTER> |
---|
| 457 | @end html |
---|
| 458 | @end ifset |
---|
| 459 | |
---|
[75e22db] | 460 | Mode values are specifically designed to be mutually exclusive, therefore |
---|
| 461 | bitwise OR and addition operations are equivalent as long as each mode |
---|
| 462 | appears exactly once in the component list. A mode component listed as a |
---|
| 463 | default is not required to appear in the mode component list, although it |
---|
| 464 | is a good programming practice to specify default components. If all |
---|
| 465 | defaults are desired, the mode @code{@value{RPREFIX}DEFAULT_MODES} and the |
---|
| 466 | mask @code{@value{RPREFIX}ALL_MODE_MASKS} should be used. |
---|
| 467 | |
---|
| 468 | The following example demonstrates the mode and mask parameters used with |
---|
| 469 | the @code{@value{DIRPREFIX}task_mode} |
---|
| 470 | directive to place a task at interrupt level 3 and make it |
---|
| 471 | non-preemptible. The mode should be set to |
---|
| 472 | @code{@value{RPREFIX}INTERRUPT_LEVEL(3) @value{OR} |
---|
| 473 | @value{RPREFIX}NO_PREEMPT} to indicate the desired preemption mode and |
---|
| 474 | interrupt level, while the mask parameter should be set to |
---|
| 475 | @code{@value{RPREFIX}INTERRUPT_MASK @value{OR} |
---|
| 476 | @value{RPREFIX}NO_PREEMPT_MASK} to indicate that the calling task's |
---|
| 477 | interrupt level and preemption mode are being altered. |
---|
[ae68ff0] | 478 | |
---|
| 479 | @section Operations |
---|
| 480 | |
---|
| 481 | @subsection Creating Tasks |
---|
| 482 | |
---|
[75e22db] | 483 | The @code{@value{DIRPREFIX}task_create} |
---|
| 484 | directive creates a task by allocating a task |
---|
[ae68ff0] | 485 | control block, assigning the task a user-specified name, |
---|
| 486 | allocating it a stack and floating point context area, setting a |
---|
| 487 | user-specified initial priority, setting a user-specified |
---|
| 488 | initial mode, and assigning it a task ID. Newly created tasks |
---|
| 489 | are initially placed in the dormant state. All RTEMS tasks |
---|
| 490 | execute in the most privileged mode of the processor. |
---|
| 491 | |
---|
| 492 | @subsection Obtaining Task IDs |
---|
| 493 | |
---|
| 494 | When a task is created, RTEMS generates a unique task ID and |
---|
| 495 | assigns it to the created task until it is deleted. The task ID |
---|
| 496 | may be obtained by either of two methods. First, as the result |
---|
[75e22db] | 497 | of an invocation of the @code{@value{DIRPREFIX}task_create} |
---|
| 498 | directive, the task ID is |
---|
[ae68ff0] | 499 | stored in a user provided location. Second, the task ID may be |
---|
[75e22db] | 500 | obtained later using the @code{@value{DIRPREFIX}task_ident} |
---|
| 501 | directive. The task ID is |
---|
[ae68ff0] | 502 | used by other directives to manipulate this task. |
---|
| 503 | |
---|
| 504 | @subsection Starting and Restarting Tasks |
---|
| 505 | |
---|
[75e22db] | 506 | The @code{@value{DIRPREFIX}task_start} |
---|
| 507 | directive is used to place a dormant task in the |
---|
[ae68ff0] | 508 | ready state. This enables the task to compete, based on its |
---|
| 509 | current priority, for the processor and other system resources. |
---|
| 510 | Any actions, such as suspension or change of priority, performed |
---|
| 511 | on a task prior to starting it are nullified when the task is |
---|
| 512 | started. |
---|
| 513 | |
---|
[75e22db] | 514 | With the @code{@value{DIRPREFIX}task_start} |
---|
| 515 | directive the user specifies the task's |
---|
[ae68ff0] | 516 | starting address and argument. The argument is used to |
---|
| 517 | communicate some startup information to the task. As part of |
---|
| 518 | this directive, RTEMS initializes the task's stack based upon |
---|
| 519 | the task's initial execution mode and start address. The |
---|
| 520 | starting argument is passed to the task in accordance with the |
---|
| 521 | target processor's calling convention. |
---|
| 522 | |
---|
[75e22db] | 523 | The @code{@value{DIRPREFIX}task_restart} |
---|
| 524 | directive restarts a task at its initial |
---|
[ae68ff0] | 525 | starting address with its original priority and execution mode, |
---|
| 526 | but with a possibly different argument. The new argument may be |
---|
| 527 | used to distinguish between the original invocation of the task |
---|
| 528 | and subsequent invocations. The task's stack and control block |
---|
| 529 | are modified to reflect their original creation values. |
---|
| 530 | Although references to resources that have been requested are |
---|
| 531 | cleared, resources allocated by the task are NOT automatically |
---|
| 532 | returned to RTEMS. A task cannot be restarted unless it has |
---|
| 533 | previously been started (i.e. dormant tasks cannot be |
---|
| 534 | restarted). All restarted tasks are placed in the ready state. |
---|
| 535 | |
---|
| 536 | @subsection Suspending and Resuming Tasks |
---|
| 537 | |
---|
[75e22db] | 538 | The @code{@value{DIRPREFIX}task_suspend} |
---|
| 539 | directive is used to place either the caller or |
---|
[ae68ff0] | 540 | another task into a suspended state. The task remains suspended |
---|
[75e22db] | 541 | until a @code{@value{DIRPREFIX}task_resume} |
---|
| 542 | directive is issued. This implies that a |
---|
[ae68ff0] | 543 | task may be suspended as well as blocked waiting either to |
---|
| 544 | acquire a resource or for the expiration of a timer. |
---|
| 545 | |
---|
[75e22db] | 546 | The @code{@value{DIRPREFIX}task_resume} |
---|
| 547 | directive is used to remove another task from |
---|
[ae68ff0] | 548 | the suspended state. If the task is not also blocked, resuming |
---|
| 549 | it will place it in the ready state, allowing it to once again |
---|
| 550 | compete for the processor and resources. If the task was |
---|
| 551 | blocked as well as suspended, this directive clears the |
---|
| 552 | suspension and leaves the task in the blocked state. |
---|
| 553 | |
---|
[1ca951ce] | 554 | Suspending a task which is already suspended or resuming a |
---|
| 555 | task which is not suspended is considered an error. |
---|
[5ad8673] | 556 | The @code{@value{DIRPREFIX}task_is_suspended} can be used to |
---|
| 557 | determine if a task is currently suspended. |
---|
[1ca951ce] | 558 | |
---|
[ae68ff0] | 559 | @subsection Delaying the Currently Executing Task |
---|
| 560 | |
---|
[75e22db] | 561 | The @code{@value{DIRPREFIX}task_wake_after} directive creates a sleep timer |
---|
| 562 | which allows a task to go to sleep for a specified interval. The task is |
---|
| 563 | blocked until the delay interval has elapsed, at which time the task is |
---|
| 564 | unblocked. A task calling the @code{@value{DIRPREFIX}task_wake_after} |
---|
| 565 | directive with a delay |
---|
| 566 | interval of @code{@value{RPREFIX}YIELD_PROCESSOR} ticks will yield the |
---|
| 567 | processor to any other ready task of equal or greater priority and remain |
---|
| 568 | ready to execute. |
---|
| 569 | |
---|
| 570 | The @code{@value{DIRPREFIX}task_wake_when} |
---|
| 571 | directive creates a sleep timer which allows |
---|
[ae68ff0] | 572 | a task to go to sleep until a specified date and time. The |
---|
| 573 | calling task is blocked until the specified date and time has |
---|
| 574 | occurred, at which time the task is unblocked. |
---|
| 575 | |
---|
| 576 | @subsection Changing Task Priority |
---|
| 577 | |
---|
[75e22db] | 578 | The @code{@value{DIRPREFIX}task_set_priority} |
---|
| 579 | directive is used to obtain or change the |
---|
[ae68ff0] | 580 | current priority of either the calling task or another task. If |
---|
[75e22db] | 581 | the new priority requested is |
---|
| 582 | @code{@value{RPREFIX}CURRENT_PRIORITY} or the task's |
---|
[ae68ff0] | 583 | actual priority, then the current priority will be returned and |
---|
| 584 | the task's priority will remain unchanged. If the task's |
---|
| 585 | priority is altered, then the task will be scheduled according |
---|
| 586 | to its new priority. |
---|
| 587 | |
---|
[75e22db] | 588 | The @code{@value{DIRPREFIX}task_restart} |
---|
| 589 | directive resets the priority of a task to its |
---|
[ae68ff0] | 590 | original value. |
---|
| 591 | |
---|
| 592 | @subsection Changing Task Mode |
---|
| 593 | |
---|
[75e22db] | 594 | The @code{@value{DIRPREFIX}task_mode} |
---|
| 595 | directive is used to obtain or change the current |
---|
[ae68ff0] | 596 | execution mode of the calling task. A task's execution mode is |
---|
| 597 | used to enable preemption, timeslicing, ASR processing, and to |
---|
| 598 | set the task's interrupt level. |
---|
| 599 | |
---|
[75e22db] | 600 | The @code{@value{DIRPREFIX}task_restart} |
---|
| 601 | directive resets the mode of a task to its |
---|
[ae68ff0] | 602 | original value. |
---|
| 603 | |
---|
| 604 | @subsection Notepad Locations |
---|
| 605 | |
---|
| 606 | RTEMS provides sixteen notepad locations for each task. Each |
---|
| 607 | notepad location may contain a note consisting of four bytes of |
---|
[75e22db] | 608 | information. RTEMS provides two directives, |
---|
| 609 | @code{@value{DIRPREFIX}task_set_note} and |
---|
| 610 | @code{@value{DIRPREFIX}task_get_note}, that enable a user |
---|
| 611 | to access and change the |
---|
| 612 | notepad locations. The @code{@value{DIRPREFIX}task_set_note} |
---|
| 613 | directive enables the user |
---|
[ae68ff0] | 614 | to set a task's notepad entry to a specified note. The |
---|
[75e22db] | 615 | @code{@value{DIRPREFIX}task_get_note} |
---|
| 616 | directive allows the user to obtain the note |
---|
[ae68ff0] | 617 | contained in any one of the sixteen notepads of a specified task. |
---|
| 618 | |
---|
| 619 | @subsection Task Deletion |
---|
| 620 | |
---|
[75e22db] | 621 | RTEMS provides the @code{@value{DIRPREFIX}task_delete} |
---|
| 622 | directive to allow a task to |
---|
[ae68ff0] | 623 | delete itself or any other task. This directive removes all |
---|
| 624 | RTEMS references to the task, frees the task's control block, |
---|
| 625 | removes it from resource wait queues, and deallocates its stack |
---|
| 626 | as well as the optional floating point context. The task's name |
---|
| 627 | and ID become inactive at this time, and any subsequent |
---|
| 628 | references to either of them is invalid. In fact, RTEMS may |
---|
| 629 | reuse the task ID for another task which is created later in the |
---|
| 630 | application. |
---|
| 631 | |
---|
[75e22db] | 632 | Unexpired delay timers (i.e. those used by |
---|
| 633 | @code{@value{DIRPREFIX}task_wake_after} and |
---|
| 634 | @code{@value{DIRPREFIX}task_wake_when}) and |
---|
| 635 | timeout timers associated with the task are |
---|
[ae68ff0] | 636 | automatically deleted, however, other resources dynamically |
---|
| 637 | allocated by the task are NOT automatically returned to RTEMS. |
---|
| 638 | Therefore, before a task is deleted, all of its dynamically |
---|
| 639 | allocated resources should be deallocated by the user. This may |
---|
| 640 | be accomplished by instructing the task to delete itself rather |
---|
| 641 | than directly deleting the task. Other tasks may instruct a |
---|
| 642 | task to delete itself by sending a "delete self" message, event, |
---|
| 643 | or signal, or by restarting the task with special arguments |
---|
| 644 | which instruct the task to delete itself. |
---|
| 645 | |
---|
| 646 | @section Directives |
---|
| 647 | |
---|
| 648 | This section details the task manager's directives. A |
---|
| 649 | subsection is dedicated to each of this manager's directives and |
---|
| 650 | describes the calling sequence, related constants, usage, and |
---|
| 651 | status codes. |
---|
| 652 | |
---|
| 653 | @page |
---|
| 654 | |
---|
| 655 | @subsection TASK_CREATE - Create a task |
---|
| 656 | |
---|
[169502e] | 657 | @cindex create a task |
---|
| 658 | |
---|
[ae68ff0] | 659 | @subheading CALLING SEQUENCE: |
---|
[61389eac] | 660 | |
---|
| 661 | @ifset is-C |
---|
[169502e] | 662 | @findex rtems_task_create |
---|
[ae68ff0] | 663 | @example |
---|
| 664 | rtems_status_code rtems_task_create( |
---|
| 665 | rtems_name name, |
---|
| 666 | rtems_task_priority initial_priority, |
---|
| 667 | rtems_unsigned32 stack_size, |
---|
| 668 | rtems_mode initial_modes, |
---|
| 669 | rtems_attribute attribute_set, |
---|
| 670 | rtems_id *id |
---|
| 671 | ); |
---|
| 672 | @end example |
---|
[61389eac] | 673 | @end ifset |
---|
| 674 | |
---|
| 675 | @ifset is-Ada |
---|
| 676 | @example |
---|
| 677 | procedure Task_Create ( |
---|
| 678 | Name : in RTEMS.Name; |
---|
| 679 | Initial_Priority : in RTEMS.Task_Priority; |
---|
| 680 | Stack_Size : in RTEMS.Unsigned32; |
---|
| 681 | Initial_Modes : in RTEMS.Mode; |
---|
| 682 | Attribute_Set : in RTEMS.Attribute; |
---|
| 683 | ID : out RTEMS.ID; |
---|
| 684 | Result : out RTEMS.Status_Codes |
---|
| 685 | ); |
---|
| 686 | @end example |
---|
| 687 | @end ifset |
---|
[ae68ff0] | 688 | |
---|
| 689 | @subheading DIRECTIVE STATUS CODES: |
---|
[a3a7527] | 690 | @code{@value{RPREFIX}SUCCESSFUL} - task created successfully@* |
---|
[f331481c] | 691 | @code{@value{RPREFIX}INVALID_NAME} - invalid task name@* |
---|
| 692 | @code{@value{RPREFIX}INVALID_SIZE} - stack too small@* |
---|
| 693 | @code{@value{RPREFIX}INVALID_PRIORITY} - invalid task priority@* |
---|
| 694 | @code{@value{RPREFIX}MP_NOT_CONFIGURED} - multiprocessing not configured@* |
---|
| 695 | @code{@value{RPREFIX}TOO_MANY} - too many tasks created@* |
---|
| 696 | @code{@value{RPREFIX}UNSATISFIED} - not enough memory for stack/FP context@* |
---|
| 697 | @code{@value{RPREFIX}TOO_MANY} - too many global objects |
---|
[ae68ff0] | 698 | |
---|
| 699 | @subheading DESCRIPTION: |
---|
| 700 | This directive creates a task which resides on the local node. |
---|
[b95914f] | 701 | It allocates and initializes a TCB, a stack, and an optional |
---|
[ae68ff0] | 702 | floating point context area. The mode parameter contains values |
---|
| 703 | which sets the task's initial execution mode. The |
---|
[75e22db] | 704 | @code{@value{RPREFIX}FLOATING_POINT} attribute should be |
---|
| 705 | specified if the created task |
---|
[ae68ff0] | 706 | is to use a numeric coprocessor. For performance reasons, it is |
---|
| 707 | recommended that tasks not using the numeric coprocessor should |
---|
[75e22db] | 708 | specify the @code{@value{RPREFIX}NO_FLOATING_POINT} attribute. |
---|
| 709 | If the @code{@value{RPREFIX}GLOBAL} |
---|
[ae68ff0] | 710 | attribute is specified, the task can be accessed from remote |
---|
| 711 | nodes. The task id, returned in id, is used in other task |
---|
| 712 | related directives to access the task. When created, a task is |
---|
| 713 | placed in the dormant state and can only be made ready to |
---|
[75e22db] | 714 | execute using the directive @code{@value{DIRPREFIX}task_start}. |
---|
[ae68ff0] | 715 | |
---|
| 716 | @subheading NOTES: |
---|
| 717 | This directive will not cause the calling task to be preempted. |
---|
| 718 | |
---|
| 719 | Valid task priorities range from a high of 1 to a low of 255. |
---|
| 720 | |
---|
| 721 | RTEMS supports a maximum of 256 interrupt levels which are |
---|
| 722 | mapped onto the interrupt levels actually supported by the |
---|
| 723 | target processor. |
---|
| 724 | |
---|
[75e22db] | 725 | The requested stack size should be at least |
---|
| 726 | @code{@value{RPREFIX}MINIMUM_STACK_SIZE} |
---|
| 727 | bytes. The value of @code{@value{RPREFIX}MINIMUM_STACK_SIZE} |
---|
| 728 | is processor dependent. |
---|
[ae68ff0] | 729 | Application developers should consider the stack usage of the |
---|
| 730 | device drivers when calculating the stack size required for |
---|
| 731 | tasks which utilize the driver. |
---|
| 732 | |
---|
| 733 | The following task attribute constants are defined by RTEMS: |
---|
| 734 | |
---|
| 735 | @itemize @bullet |
---|
[f331481c] | 736 | @item @code{@value{RPREFIX}NO_FLOATING_POINT} - does not use coprocessor (default) |
---|
| 737 | @item @code{@value{RPREFIX}FLOATING_POINT} - uses numeric coprocessor |
---|
| 738 | @item @code{@value{RPREFIX}LOCAL} - local task (default) |
---|
| 739 | @item @code{@value{RPREFIX}GLOBAL} - global task |
---|
[ae68ff0] | 740 | @end itemize |
---|
| 741 | |
---|
| 742 | The following task mode constants are defined by RTEMS: |
---|
| 743 | |
---|
| 744 | @itemize @bullet |
---|
[f331481c] | 745 | @item @code{@value{RPREFIX}PREEMPT} - enable preemption (default) |
---|
| 746 | @item @code{@value{RPREFIX}NO_PREEMPT} - disable preemption |
---|
| 747 | @item @code{@value{RPREFIX}NO_TIMESLICE} - disable timeslicing (default) |
---|
| 748 | @item @code{@value{RPREFIX}TIMESLICE} - enable timeslicing |
---|
| 749 | @item @code{@value{RPREFIX}ASR} - enable ASR processing (default) |
---|
| 750 | @item @code{@value{RPREFIX}NO_ASR} - disable ASR processing |
---|
[a3a7527] | 751 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} - enable all interrupts (default) |
---|
| 752 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} - execute at interrupt level n |
---|
[ae68ff0] | 753 | @end itemize |
---|
| 754 | |
---|
| 755 | Tasks should not be made global unless remote tasks must |
---|
| 756 | interact with them. This avoids the system overhead incurred by |
---|
| 757 | the creation of a global task. When a global task is created, |
---|
| 758 | the task's name and id must be transmitted to every node in the |
---|
| 759 | system for insertion in the local copy of the global object |
---|
| 760 | table. |
---|
| 761 | |
---|
| 762 | The total number of global objects, including tasks, is limited |
---|
| 763 | by the maximum_global_objects field in the Configuration Table. |
---|
| 764 | |
---|
| 765 | @page |
---|
| 766 | |
---|
| 767 | @subsection TASK_IDENT - Get ID of a task |
---|
| 768 | |
---|
[169502e] | 769 | @cindex get ID of a task |
---|
| 770 | |
---|
[ae68ff0] | 771 | @subheading CALLING SEQUENCE: |
---|
[61389eac] | 772 | |
---|
| 773 | @ifset is-C |
---|
[169502e] | 774 | @findex rtems_task_ident |
---|
[ae68ff0] | 775 | @example |
---|
| 776 | rtems_status_code rtems_task_ident( |
---|
| 777 | rtems_name name, |
---|
| 778 | rtems_unsigned32 node, |
---|
| 779 | rtems_id *id |
---|
| 780 | ); |
---|
| 781 | @end example |
---|
[61389eac] | 782 | @end ifset |
---|
| 783 | |
---|
| 784 | @ifset is-Ada |
---|
| 785 | @example |
---|
| 786 | procedure Task_Ident ( |
---|
| 787 | Name : in RTEMS.Name; |
---|
| 788 | Node : in RTEMS.Node; |
---|
| 789 | ID : out RTEMS.ID; |
---|
| 790 | Result : out RTEMS.Status_Codes |
---|
| 791 | ); |
---|
| 792 | @end example |
---|
| 793 | @end ifset |
---|
[ae68ff0] | 794 | |
---|
| 795 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 796 | @code{@value{RPREFIX}SUCCESSFUL} - task identified successfully@* |
---|
| 797 | @code{@value{RPREFIX}INVALID_NAME} - invalid task name@* |
---|
| 798 | @code{@value{RPREFIX}INVALID_NODE} - invalid node id |
---|
[ae68ff0] | 799 | |
---|
| 800 | @subheading DESCRIPTION: |
---|
| 801 | This directive obtains the task id associated with the task name |
---|
| 802 | specified in name. A task may obtain its own id by specifying |
---|
[f331481c] | 803 | @code{@value{RPREFIX}SELF} or its own task name in name. If the task name is not |
---|
[ae68ff0] | 804 | unique, then the task id returned will match one of the tasks |
---|
| 805 | with that name. However, this task id is not guaranteed to |
---|
| 806 | correspond to the desired task. The task id, returned in id, is |
---|
| 807 | used in other task related directives to access the task. |
---|
| 808 | |
---|
| 809 | @subheading NOTES: |
---|
| 810 | This directive will not cause the running task to be preempted. |
---|
| 811 | |
---|
[f331481c] | 812 | If node is @code{@value{RPREFIX}SEARCH_ALL_NODES}, all nodes are searched with the |
---|
[ae68ff0] | 813 | local node being searched first. All other nodes are searched |
---|
| 814 | with the lowest numbered node searched first. |
---|
| 815 | |
---|
| 816 | If node is a valid node number which does not represent the |
---|
| 817 | local node, then only the tasks exported by the designated node |
---|
| 818 | are searched. |
---|
| 819 | |
---|
| 820 | This directive does not generate activity on remote nodes. It |
---|
| 821 | accesses only the local copy of the global object table. |
---|
| 822 | |
---|
| 823 | @page |
---|
| 824 | |
---|
| 825 | @subsection TASK_START - Start a task |
---|
| 826 | |
---|
[169502e] | 827 | @cindex starting a task |
---|
| 828 | |
---|
[ae68ff0] | 829 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 830 | |
---|
[61389eac] | 831 | @ifset is-C |
---|
[169502e] | 832 | @findex rtems_task_start |
---|
[ae68ff0] | 833 | @example |
---|
| 834 | rtems_status_code rtems_task_start( |
---|
| 835 | rtems_id id, |
---|
| 836 | rtems_task_entry entry_point, |
---|
| 837 | rtems_task_argument argument |
---|
| 838 | ); |
---|
| 839 | @end example |
---|
[61389eac] | 840 | @end ifset |
---|
| 841 | |
---|
| 842 | @ifset is-Ada |
---|
| 843 | @example |
---|
| 844 | procedure Task_Start ( |
---|
| 845 | ID : in RTEMS.ID; |
---|
| 846 | Entry_Point : in System.Address; |
---|
| 847 | Argument : in RTEMS.Task_Argument_PTR; |
---|
| 848 | Result : out RTEMS.Status_Codes |
---|
| 849 | ); |
---|
| 850 | @end example |
---|
| 851 | @end ifset |
---|
[ae68ff0] | 852 | |
---|
| 853 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 854 | @code{@value{RPREFIX}SUCCESSFUL} - ask started successfully@* |
---|
| 855 | @code{@value{RPREFIX}INVALID_ADDRESS} - invalid task entry point@* |
---|
| 856 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
| 857 | @code{@value{RPREFIX}INCORRECT_STATE} - task not in the dormant state@* |
---|
| 858 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - cannot start remote task |
---|
[ae68ff0] | 859 | |
---|
| 860 | @subheading DESCRIPTION: |
---|
| 861 | This directive readies the task, specified by tid, for execution |
---|
| 862 | based on the priority and execution mode specified when the task |
---|
| 863 | was created. The starting address of the task is given in |
---|
| 864 | entry_point. The task's starting argument is contained in |
---|
| 865 | argument. This argument can be a single value or used as an |
---|
| 866 | index into an array of parameter blocks. |
---|
| 867 | |
---|
| 868 | @subheading NOTES: |
---|
| 869 | The calling task will be preempted if its preemption mode is |
---|
| 870 | enabled and the task being started has a higher priority. |
---|
| 871 | |
---|
| 872 | Any actions performed on a dormant task such as suspension or |
---|
| 873 | change of priority are nullified when the task is initiated via |
---|
[75e22db] | 874 | the @code{@value{DIRPREFIX}task_start} directive. |
---|
[ae68ff0] | 875 | |
---|
| 876 | @page |
---|
| 877 | |
---|
| 878 | @subsection TASK_RESTART - Restart a task |
---|
| 879 | |
---|
[169502e] | 880 | @cindex restarting a task |
---|
| 881 | |
---|
[ae68ff0] | 882 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 883 | |
---|
[61389eac] | 884 | @ifset is-C |
---|
[169502e] | 885 | @findex rtems_task_restart |
---|
[ae68ff0] | 886 | @example |
---|
| 887 | rtems_status_code rtems_task_restart( |
---|
| 888 | rtems_id id, |
---|
| 889 | rtems_task_argument argument |
---|
| 890 | ); |
---|
| 891 | @end example |
---|
[61389eac] | 892 | @end ifset |
---|
| 893 | |
---|
| 894 | @ifset is-Ada |
---|
| 895 | @example |
---|
| 896 | procedure Task_Restart ( |
---|
| 897 | ID : in RTEMS.ID; |
---|
| 898 | Argument : in RTEMS.Task_Argument_PTR; |
---|
| 899 | Result : out RTEMS.Status_Codes |
---|
| 900 | ); |
---|
| 901 | @end example |
---|
| 902 | @end ifset |
---|
[ae68ff0] | 903 | |
---|
| 904 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 905 | @code{@value{RPREFIX}SUCCESSFUL} - task restarted successfully@* |
---|
| 906 | @code{@value{RPREFIX}INVALID_ID} - task id invalid@* |
---|
| 907 | @code{@value{RPREFIX}INCORRECT_STATE} - task never started@* |
---|
| 908 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - cannot restart remote task |
---|
[ae68ff0] | 909 | |
---|
| 910 | @subheading DESCRIPTION: |
---|
| 911 | This directive resets the task specified by id to begin |
---|
| 912 | execution at its original starting address. The task's priority |
---|
| 913 | and execution mode are set to the original creation values. If |
---|
| 914 | the task is currently blocked, RTEMS automatically makes the |
---|
| 915 | task ready. A task can be restarted from any state, except the |
---|
| 916 | dormant state. |
---|
| 917 | |
---|
| 918 | The task's starting argument is contained in argument. This |
---|
| 919 | argument can be a single value or an index into an array of |
---|
| 920 | parameter blocks. This new argument may be used to distinguish |
---|
[75e22db] | 921 | between the initial @code{@value{DIRPREFIX}task_start} |
---|
| 922 | of the task and any ensuing calls |
---|
| 923 | to @code{@value{DIRPREFIX}task_restart} |
---|
| 924 | of the task. This can be beneficial in deleting |
---|
| 925 | a task. Instead of deleting a task using |
---|
| 926 | the @code{@value{DIRPREFIX}task_delete} |
---|
[ae68ff0] | 927 | directive, a task can delete another task by restarting that |
---|
| 928 | task, and allowing that task to release resources back to RTEMS |
---|
| 929 | and then delete itself. |
---|
| 930 | |
---|
| 931 | @subheading NOTES: |
---|
[f331481c] | 932 | If id is @code{@value{RPREFIX}SELF}, the calling task will be restarted and will not |
---|
[ae68ff0] | 933 | return from this directive. |
---|
| 934 | |
---|
| 935 | The calling task will be preempted if its preemption mode is |
---|
| 936 | enabled and the task being restarted has a higher priority. |
---|
| 937 | |
---|
| 938 | The task must reside on the local node, even if the task was |
---|
[75e22db] | 939 | created with the @code{@value{RPREFIX}GLOBAL} option. |
---|
[ae68ff0] | 940 | |
---|
| 941 | @page |
---|
| 942 | |
---|
| 943 | @subsection TASK_DELETE - Delete a task |
---|
| 944 | |
---|
[169502e] | 945 | @cindex deleting a task |
---|
| 946 | |
---|
[ae68ff0] | 947 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 948 | |
---|
[61389eac] | 949 | @ifset is-C |
---|
[169502e] | 950 | @findex rtems_task_delete |
---|
[ae68ff0] | 951 | @example |
---|
| 952 | rtems_status_code rtems_task_delete( |
---|
| 953 | rtems_id id |
---|
| 954 | ); |
---|
| 955 | @end example |
---|
[61389eac] | 956 | @end ifset |
---|
| 957 | |
---|
| 958 | @ifset is-Ada |
---|
| 959 | @example |
---|
| 960 | procedure Task_Delete ( |
---|
| 961 | ID : in RTEMS.ID; |
---|
| 962 | Result : out RTEMS.Status_Codes |
---|
| 963 | ); |
---|
| 964 | @end example |
---|
| 965 | @end ifset |
---|
[ae68ff0] | 966 | |
---|
| 967 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 968 | @code{@value{RPREFIX}SUCCESSFUL} - task restarted successfully@* |
---|
| 969 | @code{@value{RPREFIX}INVALID_ID} - task id invalid@* |
---|
| 970 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - cannot restart remote task |
---|
[ae68ff0] | 971 | |
---|
| 972 | @subheading DESCRIPTION: |
---|
| 973 | This directive deletes a task, either the calling task or |
---|
| 974 | another task, as specified by id. RTEMS stops the execution of |
---|
| 975 | the task and reclaims the stack memory, any allocated delay or |
---|
[f331481c] | 976 | timeout timers, the TCB, and, if the task is @code{@value{RPREFIX}FLOATING_POINT}, its |
---|
[ae68ff0] | 977 | floating point context area. RTEMS does not reclaim the |
---|
| 978 | following resources: region segments, partition buffers, |
---|
| 979 | semaphores, timers, or rate monotonic periods. |
---|
| 980 | |
---|
| 981 | @subheading NOTES: |
---|
| 982 | A task is responsible for releasing its resources back to RTEMS |
---|
| 983 | before deletion. To insure proper deallocation of resources, a |
---|
| 984 | task should not be deleted unless it is unable to execute or |
---|
| 985 | does not hold any RTEMS resources. If a task holds RTEMS |
---|
| 986 | resources, the task should be allowed to deallocate its |
---|
| 987 | resources before deletion. A task can be directed to release |
---|
| 988 | its resources and delete itself by restarting it with a special |
---|
| 989 | argument or by sending it a message, an event, or a signal. |
---|
| 990 | |
---|
[f331481c] | 991 | Deletion of the current task (@code{@value{RPREFIX}SELF}) will force RTEMS to select |
---|
[ae68ff0] | 992 | another task to execute. |
---|
| 993 | |
---|
| 994 | When a global task is deleted, the task id must be transmitted |
---|
| 995 | to every node in the system for deletion from the local copy of |
---|
| 996 | the global object table. |
---|
| 997 | |
---|
| 998 | The task must reside on the local node, even if the task was |
---|
[75e22db] | 999 | created with the @code{@value{RPREFIX}GLOBAL} option. |
---|
[ae68ff0] | 1000 | |
---|
| 1001 | @page |
---|
| 1002 | |
---|
| 1003 | @subsection TASK_SUSPEND - Suspend a task |
---|
| 1004 | |
---|
[169502e] | 1005 | @cindex suspending a task |
---|
| 1006 | |
---|
[ae68ff0] | 1007 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1008 | |
---|
[61389eac] | 1009 | @ifset is-C |
---|
[169502e] | 1010 | @findex rtems_task_suspend |
---|
[ae68ff0] | 1011 | @example |
---|
| 1012 | rtems_status_code rtems_task_suspend( |
---|
| 1013 | rtems_id id |
---|
| 1014 | ); |
---|
| 1015 | @end example |
---|
[61389eac] | 1016 | @end ifset |
---|
| 1017 | |
---|
| 1018 | @ifset is-Ada |
---|
| 1019 | @example |
---|
| 1020 | procedure Task_Suspend ( |
---|
| 1021 | ID : in RTEMS.ID; |
---|
| 1022 | Result : out RTEMS.Status_Codes |
---|
| 1023 | ); |
---|
| 1024 | @end example |
---|
| 1025 | @end ifset |
---|
[ae68ff0] | 1026 | |
---|
| 1027 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1028 | @code{@value{RPREFIX}SUCCESSFUL} - task restarted successfully@* |
---|
| 1029 | @code{@value{RPREFIX}INVALID_ID} - task id invalid@* |
---|
| 1030 | @code{@value{RPREFIX}ALREADY_SUSPENDED} - task already suspended |
---|
[ae68ff0] | 1031 | |
---|
| 1032 | @subheading DESCRIPTION: |
---|
| 1033 | This directive suspends the task specified by id from further |
---|
| 1034 | execution by placing it in the suspended state. This state is |
---|
| 1035 | additive to any other blocked state that the task may already be |
---|
| 1036 | in. The task will not execute again until another task issues |
---|
[75e22db] | 1037 | the @code{@value{DIRPREFIX}task_resume} |
---|
| 1038 | directive for this task and any blocked state |
---|
[ae68ff0] | 1039 | has been removed. |
---|
| 1040 | |
---|
| 1041 | @subheading NOTES: |
---|
[f331481c] | 1042 | The requesting task can suspend itself by specifying @code{@value{RPREFIX}SELF} as id. |
---|
[ae68ff0] | 1043 | In this case, the task will be suspended and a successful |
---|
| 1044 | return code will be returned when the task is resumed. |
---|
| 1045 | |
---|
| 1046 | Suspending a global task which does not reside on the local node |
---|
| 1047 | will generate a request to the remote node to suspend the |
---|
| 1048 | specified task. |
---|
| 1049 | |
---|
[1ca951ce] | 1050 | If the task specified by id is already suspended, then the |
---|
[75e22db] | 1051 | @code{@value{RPREFIX}ALREADY_SUSPENDED} status code is returned. |
---|
[1ca951ce] | 1052 | |
---|
[ae68ff0] | 1053 | @page |
---|
| 1054 | |
---|
| 1055 | @subsection TASK_RESUME - Resume a task |
---|
| 1056 | |
---|
[169502e] | 1057 | @cindex resuming a task |
---|
| 1058 | |
---|
[ae68ff0] | 1059 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1060 | |
---|
[61389eac] | 1061 | @ifset is-C |
---|
[169502e] | 1062 | @findex rtems_task_resume |
---|
[ae68ff0] | 1063 | @example |
---|
| 1064 | rtems_status_code rtems_task_resume( |
---|
| 1065 | rtems_id id |
---|
| 1066 | ); |
---|
| 1067 | @end example |
---|
[61389eac] | 1068 | @end ifset |
---|
| 1069 | |
---|
| 1070 | @ifset is-Ada |
---|
| 1071 | @example |
---|
| 1072 | procedure Task_Resume ( |
---|
| 1073 | ID : in RTEMS.ID; |
---|
| 1074 | Result : out RTEMS.Status_Codes |
---|
| 1075 | ); |
---|
| 1076 | @end example |
---|
| 1077 | @end ifset |
---|
[ae68ff0] | 1078 | |
---|
| 1079 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1080 | @code{@value{RPREFIX}SUCCESSFUL} - task restarted successfully@* |
---|
| 1081 | @code{@value{RPREFIX}INVALID_ID} - task id invalid@* |
---|
| 1082 | @code{@value{RPREFIX}INCORRECT_STATE} - task not suspended |
---|
[ae68ff0] | 1083 | |
---|
| 1084 | @subheading DESCRIPTION: |
---|
| 1085 | This directive removes the task specified by id from the |
---|
| 1086 | suspended state. If the task is in the ready state after the |
---|
| 1087 | suspension is removed, then it will be scheduled to run. If the |
---|
| 1088 | task is still in a blocked state after the suspension is |
---|
| 1089 | removed, then it will remain in that blocked state. |
---|
| 1090 | |
---|
| 1091 | @subheading NOTES: |
---|
| 1092 | The running task may be preempted if its preemption mode is |
---|
| 1093 | enabled and the local task being resumed has a higher priority. |
---|
| 1094 | |
---|
| 1095 | Resuming a global task which does not reside on the local node |
---|
| 1096 | will generate a request to the remote node to resume the |
---|
| 1097 | specified task. |
---|
| 1098 | |
---|
[1ca951ce] | 1099 | If the task specified by id is not suspended, then the |
---|
[75e22db] | 1100 | @code{@value{RPREFIX}INCORRECT_STATE} status code is returned. |
---|
[1ca951ce] | 1101 | |
---|
[ae68ff0] | 1102 | @page |
---|
| 1103 | |
---|
[5ad8673] | 1104 | @subsection TASK_IS_SUSPENDED - Determine if a task is Suspended |
---|
| 1105 | |
---|
[169502e] | 1106 | @cindex is task suspended |
---|
| 1107 | |
---|
[5ad8673] | 1108 | @subheading CALLING SEQUENCE: |
---|
| 1109 | |
---|
| 1110 | @ifset is-C |
---|
[169502e] | 1111 | @findex rtems_task_is_suspended |
---|
[5ad8673] | 1112 | @example |
---|
| 1113 | rtems_status_code rtems_task_is_suspended( |
---|
| 1114 | rtems_id id |
---|
| 1115 | ); |
---|
| 1116 | @end example |
---|
| 1117 | @end ifset |
---|
| 1118 | |
---|
| 1119 | @ifset is-Ada |
---|
| 1120 | @example |
---|
| 1121 | procedure Task_Is_Suspended ( |
---|
| 1122 | ID : in RTEMS.ID; |
---|
| 1123 | Result : out RTEMS.Status_Codes |
---|
| 1124 | ); |
---|
| 1125 | @end example |
---|
| 1126 | @end ifset |
---|
| 1127 | |
---|
| 1128 | @subheading DIRECTIVE STATUS CODES: |
---|
| 1129 | @code{@value{RPREFIX}SUCCESSFUL} - task is not suspended@* |
---|
| 1130 | @code{@value{RPREFIX}ALREADY_SUSPENDED} - task is not suspended@* |
---|
| 1131 | @code{@value{RPREFIX}INVALID_ID} - task id invalid@* |
---|
| 1132 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - not supported on remote tasks |
---|
| 1133 | |
---|
| 1134 | @subheading DESCRIPTION: |
---|
| 1135 | |
---|
| 1136 | This directive returns a status code indicating whether or |
---|
| 1137 | not the specified task is currently suspended. |
---|
| 1138 | |
---|
| 1139 | @subheading NOTES: |
---|
| 1140 | |
---|
| 1141 | This operation is not currently supported on remote tasks. |
---|
| 1142 | |
---|
| 1143 | @page |
---|
| 1144 | |
---|
[ae68ff0] | 1145 | @subsection TASK_SET_PRIORITY - Set task priority |
---|
| 1146 | |
---|
[169502e] | 1147 | @findex rtems_task_set_priority |
---|
| 1148 | @cindex current task priority |
---|
| 1149 | @cindex set task priority |
---|
| 1150 | @cindex get task priority |
---|
| 1151 | @cindex obtain task priority |
---|
| 1152 | |
---|
[ae68ff0] | 1153 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1154 | |
---|
[61389eac] | 1155 | @ifset is-C |
---|
[ae68ff0] | 1156 | @example |
---|
| 1157 | rtems_status_code rtems_task_set_priority( |
---|
| 1158 | rtems_id id, |
---|
| 1159 | rtems_task_priority new_priority, |
---|
| 1160 | rtems_task_priority *old_priority |
---|
| 1161 | ); |
---|
| 1162 | @end example |
---|
[61389eac] | 1163 | @end ifset |
---|
| 1164 | |
---|
| 1165 | @ifset is-Ada |
---|
| 1166 | @example |
---|
| 1167 | procedure Task_Set_Priority ( |
---|
| 1168 | ID : in RTEMS.ID; |
---|
| 1169 | New_Priority : in RTEMS.Task_Priority; |
---|
| 1170 | Old_Priority : out RTEMS.Task_Priority; |
---|
| 1171 | Result : out RTEMS.Status_Codes |
---|
| 1172 | ); |
---|
| 1173 | @end example |
---|
| 1174 | @end ifset |
---|
[ae68ff0] | 1175 | |
---|
| 1176 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1177 | @code{@value{RPREFIX}SUCCESSFUL} - task priority set successfully@* |
---|
| 1178 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
[2a6a029f] | 1179 | @code{@value{RPREFIX}INVALID_ADDRESS} - invalid return argument pointer@* |
---|
[f331481c] | 1180 | @code{@value{RPREFIX}INVALID_PRIORITY} - invalid task priority |
---|
[ae68ff0] | 1181 | |
---|
| 1182 | @subheading DESCRIPTION: |
---|
| 1183 | This directive manipulates the priority of the task specified by |
---|
[75e22db] | 1184 | id. An id of @code{@value{RPREFIX}SELF} is used to indicate |
---|
| 1185 | the calling task. When new_priority is not equal to |
---|
| 1186 | @code{@value{RPREFIX}CURRENT_PRIORITY}, the specified |
---|
[ae68ff0] | 1187 | task's previous priority is returned in old_priority. When |
---|
[75e22db] | 1188 | new_priority is @code{@value{RPREFIX}CURRENT_PRIORITY}, |
---|
| 1189 | the specified task's current |
---|
[ae68ff0] | 1190 | priority is returned in old_priority. Valid priorities range |
---|
| 1191 | from a high of 1 to a low of 255. |
---|
| 1192 | |
---|
| 1193 | @subheading NOTES: |
---|
| 1194 | The calling task may be preempted if its preemption mode is |
---|
| 1195 | enabled and it lowers its own priority or raises another task's |
---|
| 1196 | priority. |
---|
| 1197 | |
---|
| 1198 | Setting the priority of a global task which does not reside on |
---|
| 1199 | the local node will generate a request to the remote node to |
---|
| 1200 | change the priority of the specified task. |
---|
| 1201 | |
---|
| 1202 | If the task specified by id is currently holding any binary |
---|
| 1203 | semaphores which use the priority inheritance algorithm, then |
---|
| 1204 | the task's priority cannot be lowered immediately. If the |
---|
| 1205 | task's priority were lowered immediately, then priority |
---|
| 1206 | inversion results. The requested lowering of the task's |
---|
| 1207 | priority will occur when the task has released all priority |
---|
| 1208 | inheritance binary semaphores. The task's priority can be |
---|
| 1209 | increased regardless of the task's use of priority inheritance |
---|
| 1210 | binary semaphores. |
---|
| 1211 | |
---|
| 1212 | @page |
---|
| 1213 | |
---|
[ed11cadf] | 1214 | @subsection TASK_MODE - Change the current task mode |
---|
[ae68ff0] | 1215 | |
---|
[169502e] | 1216 | @cindex current task mode |
---|
| 1217 | @cindex set task mode |
---|
| 1218 | @cindex get task mode |
---|
| 1219 | @cindex set task preemption mode |
---|
| 1220 | @cindex get task preemption mode |
---|
| 1221 | @cindex obtain task mode |
---|
| 1222 | |
---|
[ae68ff0] | 1223 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1224 | |
---|
[61389eac] | 1225 | @ifset is-C |
---|
[169502e] | 1226 | @findex rtems_task_mode |
---|
[ae68ff0] | 1227 | @example |
---|
| 1228 | rtems_status_code rtems_task_mode( |
---|
| 1229 | rtems_mode mode_set, |
---|
| 1230 | rtems_mode mask, |
---|
| 1231 | rtems_mode *previous_mode_set |
---|
| 1232 | ); |
---|
| 1233 | @end example |
---|
[61389eac] | 1234 | @end ifset |
---|
| 1235 | |
---|
| 1236 | @ifset is-Ada |
---|
| 1237 | @example |
---|
| 1238 | procedure Task_Delete ( |
---|
| 1239 | Mode_Set : in RTEMS.Mode; |
---|
| 1240 | Mask : in RTEMS.Mode; |
---|
| 1241 | Previous_Mode_Set : in RTEMS.Mode; |
---|
| 1242 | Result : out RTEMS.Status_Codes |
---|
| 1243 | ); |
---|
| 1244 | @end example |
---|
| 1245 | @end ifset |
---|
[ae68ff0] | 1246 | |
---|
| 1247 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1248 | @code{@value{RPREFIX}SUCCESSFUL} - task mode set successfully |
---|
[ae68ff0] | 1249 | |
---|
| 1250 | @subheading DESCRIPTION: |
---|
| 1251 | This directive manipulates the execution mode of the calling |
---|
| 1252 | task. A task's execution mode enables and disables preemption, |
---|
| 1253 | timeslicing, asynchronous signal processing, as well as |
---|
| 1254 | specifying the current interrupt level. To modify an execution |
---|
| 1255 | mode, the mode class(es) to be changed must be specified in the |
---|
| 1256 | mask parameter and the desired mode(s) must be specified in the |
---|
| 1257 | mode parameter. |
---|
| 1258 | |
---|
| 1259 | @subheading NOTES: |
---|
| 1260 | The calling task will be preempted if it enables preemption and |
---|
| 1261 | a higher priority task is ready to run. |
---|
| 1262 | |
---|
| 1263 | Enabling timeslicing has no effect if preemption is enabled. |
---|
| 1264 | |
---|
| 1265 | A task can obtain its current execution mode, without modifying |
---|
[75e22db] | 1266 | it, by calling this directive with a mask value of |
---|
| 1267 | @code{@value{RPREFIX}CURRENT_MODE}. |
---|
[ae68ff0] | 1268 | |
---|
| 1269 | To temporarily disable the processing of a valid ASR, a task |
---|
[75e22db] | 1270 | should call this directive with the @code{@value{RPREFIX}NO_ASR} |
---|
| 1271 | indicator specified in mode. |
---|
[ae68ff0] | 1272 | |
---|
| 1273 | The set of task mode constants and each mode's corresponding |
---|
| 1274 | mask constant is provided in the following table: |
---|
| 1275 | |
---|
| 1276 | @ifset use-ascii |
---|
| 1277 | @itemize @bullet |
---|
[75e22db] | 1278 | @item @code{@value{RPREFIX}PREEMPT} is masked by |
---|
| 1279 | @code{@value{RPREFIX}PREEMPT_MASK} and enables preemption |
---|
| 1280 | |
---|
| 1281 | @item @code{@value{RPREFIX}NO_PREEMPT} is masked by |
---|
| 1282 | @code{@value{RPREFIX}PREEMPT_MASK} and disables preemption |
---|
| 1283 | |
---|
| 1284 | @item @code{@value{RPREFIX}NO_TIMESLICE} is masked by |
---|
| 1285 | @code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing |
---|
| 1286 | |
---|
| 1287 | @item @code{@value{RPREFIX}TIMESLICE} is masked by |
---|
| 1288 | @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing |
---|
| 1289 | |
---|
| 1290 | @item @code{@value{RPREFIX}ASR} is masked by |
---|
| 1291 | @code{@value{RPREFIX}ASR_MASK} and enables ASR processing |
---|
| 1292 | |
---|
| 1293 | @item @code{@value{RPREFIX}NO_ASR} is masked by |
---|
| 1294 | @code{@value{RPREFIX}ASR_MASK} and disables ASR processing |
---|
| 1295 | |
---|
| 1296 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} is masked by |
---|
| 1297 | @code{@value{RPREFIX}INTERRUPT_MASK} and enables all interrupts |
---|
| 1298 | |
---|
| 1299 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} is masked by |
---|
| 1300 | @code{@value{RPREFIX}INTERRUPT_MASK} and sets interrupts level n |
---|
[ae68ff0] | 1301 | |
---|
| 1302 | @end itemize |
---|
| 1303 | @end ifset |
---|
| 1304 | |
---|
| 1305 | @ifset use-tex |
---|
| 1306 | @sp 1 |
---|
| 1307 | @c this is temporary |
---|
| 1308 | @itemize @bullet |
---|
[75e22db] | 1309 | @item @code{@value{RPREFIX}PREEMPT} is masked by |
---|
| 1310 | @code{@value{RPREFIX}PREEMPT_MASK} and enables preemption |
---|
| 1311 | |
---|
| 1312 | @item @code{@value{RPREFIX}NO_PREEMPT} is masked by |
---|
| 1313 | @code{@value{RPREFIX}PREEMPT_MASK} and disables preemption |
---|
| 1314 | |
---|
| 1315 | @item @code{@value{RPREFIX}NO_TIMESLICE} is masked by |
---|
| 1316 | @code{@value{RPREFIX}TIMESLICE_MASK} and disables timeslicing |
---|
| 1317 | |
---|
| 1318 | @item @code{@value{RPREFIX}TIMESLICE} is masked by |
---|
| 1319 | @code{@value{RPREFIX}TIMESLICE_MASK} and enables timeslicing |
---|
| 1320 | |
---|
| 1321 | @item @code{@value{RPREFIX}ASR} is masked by |
---|
| 1322 | @code{@value{RPREFIX}ASR_MASK} and enables ASR processing |
---|
| 1323 | |
---|
| 1324 | @item @code{@value{RPREFIX}NO_ASR} is masked by |
---|
| 1325 | @code{@value{RPREFIX}ASR_MASK} and disables ASR processing |
---|
| 1326 | |
---|
| 1327 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(0)} is masked by |
---|
| 1328 | @code{@value{RPREFIX}INTERRUPT_MASK} and enables all interrupts |
---|
| 1329 | |
---|
| 1330 | @item @code{@value{RPREFIX}INTERRUPT_LEVEL(n)} is masked by |
---|
| 1331 | @code{@value{RPREFIX}INTERRUPT_MASK} and sets interrupts level n |
---|
[ae68ff0] | 1332 | |
---|
| 1333 | @end itemize |
---|
| 1334 | |
---|
| 1335 | @tex |
---|
| 1336 | @end tex |
---|
| 1337 | @end ifset |
---|
| 1338 | |
---|
| 1339 | @ifset use-html |
---|
| 1340 | @html |
---|
| 1341 | <CENTER> |
---|
| 1342 | <TABLE COLS=3 WIDTH="80%" BORDER=2> |
---|
| 1343 | <TR><TD ALIGN=center><STRONG>Mode Constant</STRONG></TD> |
---|
| 1344 | <TD ALIGN=center><STRONG>Mask Constant</STRONG></TD> |
---|
| 1345 | <TD ALIGN=center><STRONG>Description</STRONG></TD></TR> |
---|
[75e22db] | 1346 | <TR><TD ALIGN=center>@value{RPREFIX}PREEMPT</TD> |
---|
| 1347 | <TD ALIGN=center>@value{RPREFIX}PREEMPT_MASK</TD> |
---|
[ae68ff0] | 1348 | <TD ALIGN=center>enables preemption</TD></TR> |
---|
[75e22db] | 1349 | <TR><TD ALIGN=center>@value{RPREFIX}NO_PREEMPT</TD> |
---|
| 1350 | <TD ALIGN=center>@value{RPREFIX}PREEMPT_MASK</TD> |
---|
[ae68ff0] | 1351 | <TD ALIGN=center>disables preemption</TD></TR> |
---|
[75e22db] | 1352 | <TR><TD ALIGN=center>@value{RPREFIX}NO_TIMESLICE</TD> |
---|
| 1353 | <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD> |
---|
[ae68ff0] | 1354 | <TD ALIGN=center>disables timeslicing</TD></TR> |
---|
[75e22db] | 1355 | <TR><TD ALIGN=center>@value{RPREFIX}TIMESLICE</TD> |
---|
| 1356 | <TD ALIGN=center>@value{RPREFIX}TIMESLICE_MASK</TD> |
---|
[ae68ff0] | 1357 | <TD ALIGN=center>enables timeslicing</TD></TR> |
---|
[75e22db] | 1358 | <TR><TD ALIGN=center>@value{RPREFIX}ASR</TD> |
---|
| 1359 | <TD ALIGN=center>@value{RPREFIX}ASR_MASK</TD> |
---|
[ae68ff0] | 1360 | <TD ALIGN=center>enables ASR processing</TD></TR> |
---|
[75e22db] | 1361 | <TR><TD ALIGN=center>@value{RPREFIX}NO_ASR</TD> |
---|
| 1362 | <TD ALIGN=center>@value{RPREFIX}ASR_MASK</TD> |
---|
[ae68ff0] | 1363 | <TD ALIGN=center>disables ASR processing</TD></TR> |
---|
[75e22db] | 1364 | <TR><TD ALIGN=center>@value{RPREFIX}INTERRUPT_LEVEL(0)</TD> |
---|
| 1365 | <TD ALIGN=center>@value{RPREFIX}INTERRUPT_MASK</TD> |
---|
[ae68ff0] | 1366 | <TD ALIGN=center>enables all interrupts</TD></TR> |
---|
[75e22db] | 1367 | <TR><TD ALIGN=center>@value{RPREFIX}INTERRUPT_LEVEL(n)</TD> |
---|
| 1368 | <TD ALIGN=center>@value{RPREFIX}INTERRUPT_MASK</TD> |
---|
[ae68ff0] | 1369 | <TD ALIGN=center>sets interrupts level n</TD></TR> |
---|
| 1370 | </TABLE> |
---|
| 1371 | </CENTER> |
---|
| 1372 | @end html |
---|
| 1373 | @end ifset |
---|
| 1374 | |
---|
| 1375 | @page |
---|
| 1376 | |
---|
| 1377 | @subsection TASK_GET_NOTE - Get task notepad entry |
---|
| 1378 | |
---|
[169502e] | 1379 | @cindex get task notepad entry |
---|
| 1380 | |
---|
[ae68ff0] | 1381 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1382 | |
---|
[61389eac] | 1383 | @ifset is-C |
---|
[169502e] | 1384 | @findex rtems_task_get_note |
---|
[ae68ff0] | 1385 | @example |
---|
| 1386 | rtems_status_code rtems_task_get_note( |
---|
| 1387 | rtems_id id, |
---|
| 1388 | rtems_unsigned32 notepad, |
---|
| 1389 | rtems_unsigned32 *note |
---|
| 1390 | ); |
---|
| 1391 | @end example |
---|
[61389eac] | 1392 | @end ifset |
---|
| 1393 | |
---|
| 1394 | @ifset is-Ada |
---|
| 1395 | @example |
---|
| 1396 | procedure Task_Get_Note ( |
---|
| 1397 | ID : in RTEMS.ID; |
---|
| 1398 | Notepad : in RTEMS.Notepad_Index; |
---|
| 1399 | Note : out RTEMS.Unsigned32; |
---|
| 1400 | Result : out RTEMS.Status_Codes |
---|
| 1401 | ); |
---|
| 1402 | @end example |
---|
| 1403 | @end ifset |
---|
[ae68ff0] | 1404 | |
---|
| 1405 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1406 | @code{@value{RPREFIX}SUCCESSFUL} - note obtained successfully@* |
---|
| 1407 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
| 1408 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid notepad location |
---|
[ae68ff0] | 1409 | |
---|
| 1410 | @subheading DESCRIPTION: |
---|
| 1411 | This directive returns the note contained in the notepad |
---|
| 1412 | location of the task specified by id. |
---|
| 1413 | |
---|
| 1414 | @subheading NOTES: |
---|
| 1415 | This directive will not cause the running task to be preempted. |
---|
| 1416 | |
---|
[75e22db] | 1417 | If id is set to @code{@value{RPREFIX}SELF}, |
---|
| 1418 | the calling task accesses its own notepad. |
---|
[ae68ff0] | 1419 | |
---|
| 1420 | @c This version of the paragraph avoids the overfull hbox error. |
---|
| 1421 | @c The constants NOTEPAD_0 through NOTEPAD_15 can be used to access the |
---|
| 1422 | @c sixteen notepad locations. |
---|
| 1423 | |
---|
| 1424 | The sixteen notepad locations can be accessed using the constants |
---|
[f331481c] | 1425 | @code{@value{RPREFIX}NOTEPAD_0} through @code{@value{RPREFIX}NOTEPAD_15}. |
---|
[ae68ff0] | 1426 | |
---|
| 1427 | Getting a note of a global task which does not reside on the |
---|
| 1428 | local node will generate a request to the remote node to obtain |
---|
| 1429 | the notepad entry of the specified task. |
---|
| 1430 | |
---|
| 1431 | @page |
---|
| 1432 | |
---|
| 1433 | @subsection TASK_SET_NOTE - Set task notepad entry |
---|
| 1434 | |
---|
[169502e] | 1435 | @cindex set task notepad entry |
---|
| 1436 | |
---|
[ae68ff0] | 1437 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1438 | |
---|
[61389eac] | 1439 | @ifset is-C |
---|
[169502e] | 1440 | @findex rtems_task_set_note |
---|
[ae68ff0] | 1441 | @example |
---|
| 1442 | rtems_status_code rtems_task_set_note( |
---|
| 1443 | rtems_id id, |
---|
| 1444 | rtems_unsigned32 notepad, |
---|
| 1445 | rtems_unsigned32 note |
---|
| 1446 | ); |
---|
| 1447 | @end example |
---|
[61389eac] | 1448 | @end ifset |
---|
| 1449 | |
---|
| 1450 | @ifset is-Ada |
---|
| 1451 | @example |
---|
| 1452 | procedure Task_Set_Note ( |
---|
| 1453 | ID : in RTEMS.ID; |
---|
| 1454 | Notepad : in RTEMS.Notepad_Index; |
---|
| 1455 | Note : in RTEMS.Unsigned32; |
---|
| 1456 | Result : out RTEMS.Status_Codes |
---|
| 1457 | ); |
---|
| 1458 | @end example |
---|
| 1459 | @end ifset |
---|
[ae68ff0] | 1460 | |
---|
| 1461 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1462 | @code{@value{RPREFIX}SUCCESSFUL} - task's note set successfully@* |
---|
| 1463 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
| 1464 | @code{@value{RPREFIX}INVALID_NUMBER} - invalid notepad location |
---|
[ae68ff0] | 1465 | |
---|
| 1466 | @subheading DESCRIPTION: |
---|
| 1467 | This directive sets the notepad entry for the task specified by |
---|
| 1468 | id to the value note. |
---|
| 1469 | |
---|
| 1470 | @subheading NOTES: |
---|
[75e22db] | 1471 | If id is set to @code{@value{RPREFIX}SELF}, the calling |
---|
| 1472 | task accesses its own notepad locations. |
---|
[ae68ff0] | 1473 | |
---|
| 1474 | This directive will not cause the running task to be preempted. |
---|
| 1475 | |
---|
| 1476 | @c This version of the paragraph avoids the overfull hbox error. |
---|
| 1477 | @c The constants NOTEPAD_0 through NOTEPAD_15 can be used to access the |
---|
| 1478 | @c sixteen notepad locations. |
---|
| 1479 | |
---|
| 1480 | The sixteen notepad locations can be accessed using the constants |
---|
[f331481c] | 1481 | @code{@value{RPREFIX}NOTEPAD_0} through @code{@value{RPREFIX}NOTEPAD_15}. |
---|
[ae68ff0] | 1482 | |
---|
| 1483 | Setting a notepad location of a global task which does not |
---|
| 1484 | reside on the local node will generate a request to the remote |
---|
| 1485 | node to set the specified notepad entry. |
---|
| 1486 | |
---|
| 1487 | @page |
---|
| 1488 | |
---|
| 1489 | @subsection TASK_WAKE_AFTER - Wake up after interval |
---|
| 1490 | |
---|
[169502e] | 1491 | @cindex delay a task for an interval |
---|
| 1492 | @cindex wake up after an interval |
---|
| 1493 | |
---|
[ae68ff0] | 1494 | @subheading CALLING SEQUENCE: |
---|
[87ed029] | 1495 | |
---|
[61389eac] | 1496 | @ifset is-C |
---|
[169502e] | 1497 | @findex rtems_task_wake_after |
---|
[ae68ff0] | 1498 | @example |
---|
| 1499 | rtems_status_code rtems_task_wake_after( |
---|
| 1500 | rtems_interval ticks |
---|
| 1501 | ); |
---|
| 1502 | @end example |
---|
[61389eac] | 1503 | @end ifset |
---|
| 1504 | |
---|
| 1505 | @ifset is-Ada |
---|
| 1506 | @example |
---|
| 1507 | procedure Task_Wake_After ( |
---|
| 1508 | Ticks : in RTEMS.Interval; |
---|
| 1509 | Result : out RTEMS.Status_Codes |
---|
| 1510 | ); |
---|
| 1511 | @end example |
---|
| 1512 | @end ifset |
---|
[ae68ff0] | 1513 | |
---|
| 1514 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1515 | @code{@value{RPREFIX}SUCCESSFUL} - always successful |
---|
[ae68ff0] | 1516 | |
---|
| 1517 | @subheading DESCRIPTION: |
---|
| 1518 | This directive blocks the calling task for the specified number |
---|
| 1519 | of system clock ticks. When the requested interval has elapsed, |
---|
[75e22db] | 1520 | the task is made ready. The @code{@value{DIRPREFIX}clock_tick} |
---|
| 1521 | directive automatically updates the delay period. |
---|
[ae68ff0] | 1522 | |
---|
| 1523 | @subheading NOTES: |
---|
[75e22db] | 1524 | Setting the system date and time with the |
---|
| 1525 | @code{@value{DIRPREFIX}clock_set} directive |
---|
| 1526 | has no effect on a @code{@value{DIRPREFIX}task_wake_after} blocked task. |
---|
[ae68ff0] | 1527 | |
---|
| 1528 | A task may give up the processor and remain in the ready state |
---|
[f331481c] | 1529 | by specifying a value of @code{@value{RPREFIX}YIELD_PROCESSOR} in ticks. |
---|
[ae68ff0] | 1530 | |
---|
| 1531 | The maximum timer interval that can be specified is the maximum |
---|
| 1532 | value which can be represented by the rtems_unsigned32 type. |
---|
| 1533 | |
---|
[1ca951ce] | 1534 | A clock tick is required to support the functionality of this directive. |
---|
| 1535 | |
---|
[ae68ff0] | 1536 | @page |
---|
| 1537 | |
---|
| 1538 | @subsection TASK_WAKE_WHEN - Wake up when specified |
---|
| 1539 | |
---|
[169502e] | 1540 | @cindex delay a task until a wall time |
---|
| 1541 | @cindex wake up at a wall time |
---|
| 1542 | |
---|
[ae68ff0] | 1543 | @subheading CALLING SEQUENCE: |
---|
| 1544 | |
---|
[61389eac] | 1545 | @ifset is-C |
---|
[169502e] | 1546 | @findex rtems_task_wake_when |
---|
[ae68ff0] | 1547 | @example |
---|
| 1548 | rtems_status_code rtems_task_wake_when( |
---|
| 1549 | rtems_time_of_day *time_buffer |
---|
| 1550 | ); |
---|
| 1551 | @end example |
---|
[61389eac] | 1552 | @end ifset |
---|
| 1553 | |
---|
| 1554 | @ifset is-Ada |
---|
| 1555 | @example |
---|
| 1556 | procedure Task_Wake_When ( |
---|
| 1557 | Time_Buffer : in RTEMS.Time_Of_Day; |
---|
| 1558 | Result : out RTEMS.Status_Codes |
---|
| 1559 | ); |
---|
| 1560 | @end example |
---|
| 1561 | @end ifset |
---|
[ae68ff0] | 1562 | |
---|
| 1563 | @subheading DIRECTIVE STATUS CODES: |
---|
[f331481c] | 1564 | @code{@value{RPREFIX}SUCCESSFUL} - awakened at date/time successfully@* |
---|
[ae68ff0] | 1565 | @code{INVALID_TIME_OF_DAY} - invalid time buffer@* |
---|
[f331481c] | 1566 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set |
---|
[ae68ff0] | 1567 | |
---|
| 1568 | @subheading DESCRIPTION: |
---|
| 1569 | This directive blocks a task until the date and time specified |
---|
| 1570 | in time_buffer. At the requested date and time, the calling |
---|
| 1571 | task will be unblocked and made ready to execute. |
---|
| 1572 | |
---|
| 1573 | @subheading NOTES: |
---|
[7e8a1fc] | 1574 | The ticks portion of time_buffer @value{STRUCTURE} is ignored. The |
---|
[ae68ff0] | 1575 | timing granularity of this directive is a second. |
---|
[1ca951ce] | 1576 | |
---|
| 1577 | A clock tick is required to support the functionality of this directive. |
---|
[dc2b337] | 1578 | |
---|
| 1579 | @page |
---|
| 1580 | |
---|
| 1581 | @subsection TASK_VARIABLE_ADD - Associate per task variable |
---|
| 1582 | |
---|
| 1583 | @cindex per-task variable |
---|
| 1584 | @cindex task private variable |
---|
| 1585 | @cindex task private data |
---|
| 1586 | |
---|
| 1587 | @subheading CALLING SEQUENCE: |
---|
| 1588 | |
---|
| 1589 | @ifset is-C |
---|
| 1590 | @findex rtems_task_variable_add |
---|
| 1591 | @example |
---|
| 1592 | rtems_status_code rtems_task_variable_add( |
---|
| 1593 | rtems_id tid, |
---|
| 1594 | int *ptr |
---|
| 1595 | ); |
---|
| 1596 | @end example |
---|
| 1597 | @end ifset |
---|
| 1598 | |
---|
| 1599 | @ifset is-Ada |
---|
| 1600 | @example |
---|
| 1601 | procedure Task_Variable_Add ( |
---|
| 1602 | Id : in RTEMS.ID; |
---|
| 1603 | Ptr : in RTEMS.Address; |
---|
| 1604 | Result : out RTEMS.Status_Codes |
---|
| 1605 | ); |
---|
| 1606 | @end example |
---|
| 1607 | @end ifset |
---|
| 1608 | |
---|
| 1609 | @subheading DIRECTIVE STATUS CODES: |
---|
| 1610 | @code{@value{RPREFIX}SUCCESSFUL} - per task variable added successfully@* |
---|
| 1611 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
| 1612 | @code{@value{RPREFIX}NO_MEMORY} - invalid task id@* |
---|
| 1613 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - not supported on remote tasks |
---|
| 1614 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set |
---|
| 1615 | |
---|
| 1616 | @subheading DESCRIPTION: |
---|
| 1617 | This directive adds the memory location specified by the |
---|
| 1618 | ptr argument to the context of the given task. The variable will |
---|
| 1619 | then be private to the task. The task can access and modify the |
---|
| 1620 | variable, but the modifications will not appear to other tasks, and |
---|
| 1621 | other tasks' modifications to that variable will not affect the value |
---|
| 1622 | seen by the task. This is accomplished by saving and restoring the |
---|
| 1623 | variable's value each time a task switch occurs to or from the calling task. |
---|
| 1624 | |
---|
| 1625 | @subheading NOTES: |
---|
| 1626 | |
---|
| 1627 | Task variables increase the context switch time to and from the |
---|
| 1628 | tasks that own them so it is desirable to minimize the number of |
---|
| 1629 | task variables. One efficient method |
---|
| 1630 | is to have a single task variable that is a pointer to a dynamically |
---|
| 1631 | allocated structure containing the task's private `global' data. |
---|
| 1632 | |
---|
| 1633 | @page |
---|
| 1634 | |
---|
| 1635 | @subsection TASK_VARIABLE_DELETE - Remove per task variable |
---|
| 1636 | |
---|
| 1637 | @cindex per-task variable |
---|
| 1638 | @cindex task private variable |
---|
| 1639 | @cindex task private data |
---|
| 1640 | |
---|
| 1641 | @subheading CALLING SEQUENCE: |
---|
| 1642 | |
---|
| 1643 | @ifset is-C |
---|
| 1644 | @findex rtems_task_variable_delete |
---|
| 1645 | @example |
---|
| 1646 | rtems_status_code rtems_task_variable_delete( |
---|
| 1647 | rtems_id tid, |
---|
| 1648 | int *ptr |
---|
| 1649 | ); |
---|
| 1650 | @end example |
---|
| 1651 | @end ifset |
---|
| 1652 | |
---|
| 1653 | @ifset is-Ada |
---|
| 1654 | @example |
---|
| 1655 | procedure Task_Variable_Delete ( |
---|
| 1656 | Id : in RTEMS.ID; |
---|
| 1657 | Ptr : in RTEMS.Address; |
---|
| 1658 | Result : out RTEMS.Status_Codes |
---|
| 1659 | ); |
---|
| 1660 | @end example |
---|
| 1661 | @end ifset |
---|
| 1662 | |
---|
| 1663 | @subheading DIRECTIVE STATUS CODES: |
---|
| 1664 | @code{@value{RPREFIX}SUCCESSFUL} - per task variable added successfully@* |
---|
| 1665 | @code{@value{RPREFIX}INVALID_ID} - invalid task id@* |
---|
| 1666 | @code{@value{RPREFIX}NO_MEMORY} - invalid task id@* |
---|
| 1667 | @code{@value{RPREFIX}ILLEGAL_ON_REMOTE_OBJECT} - not supported on remote tasks |
---|
| 1668 | @code{@value{RPREFIX}NOT_DEFINED} - system date and time is not set |
---|
| 1669 | |
---|
| 1670 | @subheading DESCRIPTION: |
---|
| 1671 | This directive removes the given location from a task's context. |
---|
| 1672 | |
---|
| 1673 | @subheading NOTES: |
---|
| 1674 | |
---|
| 1675 | NONE |
---|
| 1676 | |
---|