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