[4b487363] | 1 | /** |
---|
| 2 | * @file rtems/rtems/tasks.h |
---|
[067a96a] | 3 | * |
---|
[61b8e9f] | 4 | * @defgroup ClassicTasks Tasks |
---|
[c5782a2] | 5 | * |
---|
[61b8e9f] | 6 | * @ingroup ClassicRTEMS |
---|
| 7 | * @brief RTEMS Tasks |
---|
[ac7d5ef0] | 8 | * |
---|
[61b8e9f] | 9 | * This include file contains all constants and structures associated |
---|
| 10 | * with RTEMS tasks. This manager provides a comprehensive set of directives |
---|
| 11 | * to create, delete, and administer tasks. |
---|
[ac7d5ef0] | 12 | * |
---|
[61b8e9f] | 13 | * Directives provided are: |
---|
| 14 | * |
---|
| 15 | * - create a task |
---|
| 16 | * - get an ID of a task |
---|
| 17 | * - start a task |
---|
| 18 | * - restart a task |
---|
| 19 | * - delete a task |
---|
| 20 | * - suspend a task |
---|
| 21 | * - resume a task |
---|
| 22 | * - set a task's priority |
---|
| 23 | * - change the current task's mode |
---|
| 24 | * - wake up after interval |
---|
| 25 | * - wake up when specified |
---|
[067a96a] | 26 | */ |
---|
| 27 | |
---|
[e95737c] | 28 | /* |
---|
[d507c037] | 29 | * COPYRIGHT (c) 1989-2014. |
---|
[61b8e9f] | 30 | * On-Line Applications Research Corporation (OAR). |
---|
[ac7d5ef0] | 31 | * |
---|
[61b8e9f] | 32 | * The license and distribution terms for this file may be |
---|
| 33 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 34 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 35 | */ |
---|
| 36 | |
---|
[092f142a] | 37 | #ifndef _RTEMS_RTEMS_TASKS_H |
---|
| 38 | #define _RTEMS_RTEMS_TASKS_H |
---|
[ac7d5ef0] | 39 | |
---|
[5e9b32b] | 40 | #include <rtems/score/object.h> |
---|
[7dfb4b9] | 41 | #include <rtems/score/scheduler.h> |
---|
[5e9b32b] | 42 | #include <rtems/score/thread.h> |
---|
[257cf74] | 43 | #include <rtems/rtems/asrdata.h> |
---|
[3a4ae6c] | 44 | #include <rtems/rtems/attr.h> |
---|
[efc227cd] | 45 | #include <rtems/rtems/eventdata.h> |
---|
[e6d4b1d] | 46 | #include <rtems/rtems/status.h> |
---|
[efc227cd] | 47 | #include <rtems/rtems/types.h> |
---|
[ac7d5ef0] | 48 | |
---|
[c404828] | 49 | #ifdef __cplusplus |
---|
| 50 | extern "C" { |
---|
[067a96a] | 51 | #endif |
---|
| 52 | |
---|
| 53 | /** |
---|
[c85ab23] | 54 | * @defgroup ClassicTasks Tasks |
---|
| 55 | * |
---|
| 56 | * @ingroup ClassicRTEMS |
---|
[067a96a] | 57 | * |
---|
[3e1ed22] | 58 | * This encapsulates the functionality of the Classic API Task Manager. |
---|
| 59 | * This functionality includes task services such as creation, deletion, |
---|
| 60 | * delays, suspend/resume, and manipulation of execution mode and priority. |
---|
[ac7d5ef0] | 61 | */ |
---|
[067a96a] | 62 | /**@{*/ |
---|
[ac7d5ef0] | 63 | |
---|
[067a96a] | 64 | /** |
---|
| 65 | * Constant to be used as the ID of current task |
---|
| 66 | */ |
---|
[ac7d5ef0] | 67 | #define RTEMS_SELF OBJECTS_ID_OF_SELF |
---|
| 68 | |
---|
[067a96a] | 69 | /** |
---|
[ac7d5ef0] | 70 | * This constant is passed to the rtems_task_wake_after directive as the |
---|
| 71 | * interval when a task wishes to yield the CPU. |
---|
| 72 | */ |
---|
[3a4ae6c] | 73 | #define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT |
---|
| 74 | |
---|
[067a96a] | 75 | /** |
---|
[3a4ae6c] | 76 | * Define the type for an RTEMS API task priority. |
---|
| 77 | */ |
---|
[254dc82] | 78 | typedef uint32_t rtems_task_priority; |
---|
[3a4ae6c] | 79 | |
---|
[2ad3d02] | 80 | /** |
---|
| 81 | * This is the constant used with the rtems_task_set_priority |
---|
| 82 | * directive to indicate that the caller wants to obtain its |
---|
| 83 | * current priority rather than set it as the name of the |
---|
| 84 | * directive indicates. |
---|
| 85 | */ |
---|
[3a4ae6c] | 86 | #define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY |
---|
| 87 | |
---|
[2ad3d02] | 88 | /** |
---|
| 89 | * This constant is the least valid value for a Classic API |
---|
| 90 | * task priority. |
---|
| 91 | */ |
---|
[3a4ae6c] | 92 | #define RTEMS_MINIMUM_PRIORITY (PRIORITY_MINIMUM + 1) |
---|
[2ad3d02] | 93 | |
---|
| 94 | /** |
---|
| 95 | * This constant is the maximum valid value for a Classic API |
---|
| 96 | * task priority. |
---|
| 97 | * |
---|
| 98 | * @note This is actually the priority of the IDLE thread so |
---|
| 99 | * using this priority will result in having a task |
---|
| 100 | * which never executes. This could be useful if you |
---|
| 101 | * want to ensure that a task does not executes during |
---|
| 102 | * certain operations such as a system mode change. |
---|
| 103 | */ |
---|
[70f559d8] | 104 | #define RTEMS_MAXIMUM_PRIORITY ((rtems_task_priority) PRIORITY_MAXIMUM) |
---|
[3a4ae6c] | 105 | |
---|
[067a96a] | 106 | /** |
---|
[3a4ae6c] | 107 | * The following constant is passed to rtems_task_set_priority when the |
---|
| 108 | * caller wants to obtain the current priority. |
---|
| 109 | */ |
---|
[50f32b11] | 110 | #define RTEMS_CURRENT_PRIORITY PRIORITY_MINIMUM |
---|
[3a4ae6c] | 111 | |
---|
[067a96a] | 112 | /** |
---|
[3a4ae6c] | 113 | * External API name for Thread_Control |
---|
| 114 | */ |
---|
| 115 | typedef Thread_Control rtems_tcb; |
---|
| 116 | |
---|
[067a96a] | 117 | /** |
---|
[3a4ae6c] | 118 | * The following defines the "return type" of an RTEMS task. |
---|
| 119 | */ |
---|
| 120 | typedef void rtems_task; |
---|
| 121 | |
---|
[067a96a] | 122 | /** |
---|
[3a4ae6c] | 123 | * The following defines the argument to an RTEMS task. |
---|
| 124 | */ |
---|
[3b14b7ad] | 125 | typedef Thread_Entry_numeric_type rtems_task_argument; |
---|
[3a4ae6c] | 126 | |
---|
[067a96a] | 127 | /** |
---|
[3a4ae6c] | 128 | * The following defines the type for the entry point of an RTEMS task. |
---|
| 129 | */ |
---|
| 130 | typedef rtems_task ( *rtems_task_entry )( |
---|
| 131 | rtems_task_argument |
---|
| 132 | ); |
---|
[50f32b11] | 133 | |
---|
[067a96a] | 134 | /** |
---|
[3a4ae6c] | 135 | * The following records define the Initialization Tasks Table. |
---|
| 136 | * Each entry contains the information required by RTEMS to |
---|
| 137 | * create and start a user task automatically at executive |
---|
| 138 | * initialization time. |
---|
| 139 | */ |
---|
| 140 | typedef struct { |
---|
[8c8fd64] | 141 | /** This is the Initialization Task's name. */ |
---|
| 142 | rtems_name name; |
---|
| 143 | /** This is the Initialization Task's stack size. */ |
---|
| 144 | size_t stack_size; |
---|
| 145 | /** This is the Initialization Task's priority. */ |
---|
| 146 | rtems_task_priority initial_priority; |
---|
| 147 | /** This is the Initialization Task's attributes. */ |
---|
| 148 | rtems_attribute attribute_set; |
---|
| 149 | /** This is the Initialization Task's entry point. */ |
---|
| 150 | rtems_task_entry entry_point; |
---|
| 151 | /** This is the Initialization Task's initial mode. */ |
---|
| 152 | rtems_mode mode_set; |
---|
| 153 | /** This is the Initialization Task's argument. */ |
---|
| 154 | rtems_task_argument argument; |
---|
[3a4ae6c] | 155 | } rtems_initialization_tasks_table; |
---|
| 156 | |
---|
[067a96a] | 157 | /** |
---|
[61b8e9f] | 158 | * @brief RTEMS Task Create |
---|
[ac7d5ef0] | 159 | * |
---|
[61b8e9f] | 160 | * This routine implements the rtems_task_create directive. The task |
---|
| 161 | * will have the name name. The attribute_set can be used to indicate |
---|
| 162 | * that the task will be globally accessible or utilize floating point. |
---|
| 163 | * The task's stack will be stack_size bytes. The task will begin |
---|
| 164 | * execution with initial_priority and initial_modes. It returns the |
---|
| 165 | * id of the created task in ID. |
---|
[4efe1955] | 166 | * |
---|
[61b8e9f] | 167 | * @param[in] name is the user defined thread name |
---|
| 168 | * @param[in] initial_priority is the thread priority |
---|
| 169 | * @param[in] stack_size is the stack size in bytes |
---|
| 170 | * @param[in] initial_modes is the initial thread mode |
---|
| 171 | * @param[in] attribute_set is the thread attributes |
---|
| 172 | * @param[in] id is the pointer to thread id |
---|
[4efe1955] | 173 | * |
---|
[61b8e9f] | 174 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
| 175 | * and *id thread id filled in |
---|
[ac7d5ef0] | 176 | */ |
---|
| 177 | rtems_status_code rtems_task_create( |
---|
[7f6a24ab] | 178 | rtems_name name, |
---|
| 179 | rtems_task_priority initial_priority, |
---|
[fb24f698] | 180 | size_t stack_size, |
---|
[7f6a24ab] | 181 | rtems_mode initial_modes, |
---|
| 182 | rtems_attribute attribute_set, |
---|
[d3b72ca3] | 183 | rtems_id *id |
---|
[ac7d5ef0] | 184 | ); |
---|
| 185 | |
---|
[067a96a] | 186 | /** |
---|
[61b8e9f] | 187 | * @brief RTEMS Task Name to Id |
---|
[ac7d5ef0] | 188 | * |
---|
[61b8e9f] | 189 | * This routine implements the rtems_task_ident directive. |
---|
| 190 | * This directive returns the task ID associated with name. |
---|
| 191 | * If more than one task is named name, then the task to |
---|
| 192 | * which the ID belongs is arbitrary. node indicates the |
---|
| 193 | * extent of the search for the ID of the task named name. |
---|
| 194 | * The search can be limited to a particular node or allowed to |
---|
| 195 | * encompass all nodes. |
---|
[4c90eb4] | 196 | * |
---|
[61b8e9f] | 197 | * @param[in] name is the user defined thread name |
---|
| 198 | * @param[in] node is(are) the node(s) to be searched |
---|
| 199 | * @param[in] id is the pointer to thread id |
---|
[4c90eb4] | 200 | * |
---|
[61b8e9f] | 201 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
| 202 | * error. Otherwise, a status code is returned indicating the |
---|
| 203 | * source of the error. If successful, the id will |
---|
| 204 | * be filled in with the thread id. |
---|
[ac7d5ef0] | 205 | */ |
---|
| 206 | rtems_status_code rtems_task_ident( |
---|
[3235ad9] | 207 | rtems_name name, |
---|
[1d496f6] | 208 | uint32_t node, |
---|
[d3b72ca3] | 209 | rtems_id *id |
---|
[ac7d5ef0] | 210 | ); |
---|
| 211 | |
---|
[067a96a] | 212 | /** |
---|
[61b8e9f] | 213 | * @brief RTEMS Delete Task |
---|
[ac7d5ef0] | 214 | * |
---|
[61b8e9f] | 215 | * This routine implements the rtems_task_delete directive. The |
---|
| 216 | * task indicated by ID is deleted. The executive halts execution |
---|
| 217 | * of the thread and frees the thread control block. |
---|
[4c90eb4] | 218 | * |
---|
[61b8e9f] | 219 | * @param[in] id is the thread id |
---|
[4c90eb4] | 220 | * |
---|
[61b8e9f] | 221 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
| 222 | * error and id is not the requesting thread. Status code is |
---|
| 223 | * returned indicating the source of the error. Nothing |
---|
| 224 | * is returned if id is the requesting thread (always succeeds). |
---|
[ac7d5ef0] | 225 | */ |
---|
| 226 | rtems_status_code rtems_task_delete( |
---|
[d3b72ca3] | 227 | rtems_id id |
---|
[ac7d5ef0] | 228 | ); |
---|
| 229 | |
---|
[e50e3f70] | 230 | void rtems_task_exit( void ) RTEMS_NO_RETURN; |
---|
| 231 | |
---|
[067a96a] | 232 | /** |
---|
[61b8e9f] | 233 | * @brief RTEMS Task Mode |
---|
[ac7d5ef0] | 234 | * |
---|
[61b8e9f] | 235 | * This routine implements the rtems_task_mode directive. The current |
---|
| 236 | * values of the modes indicated by mask of the calling task are changed |
---|
| 237 | * to that indicated in mode_set. The former mode of the task is |
---|
| 238 | * returned in mode_set. |
---|
[4c90eb4] | 239 | * |
---|
[61b8e9f] | 240 | * @param[in] mode_set is the new mode |
---|
| 241 | * @param[in] mask is the mask |
---|
| 242 | * @param[in] previous_mode_set is the address of previous mode set |
---|
[4c90eb4] | 243 | * |
---|
[61b8e9f] | 244 | * @retval RTEMS_SUCCESSFUL and previous_mode_set filled in with the |
---|
| 245 | * previous mode set |
---|
[ac7d5ef0] | 246 | */ |
---|
| 247 | rtems_status_code rtems_task_mode( |
---|
| 248 | rtems_mode mode_set, |
---|
| 249 | rtems_mode mask, |
---|
| 250 | rtems_mode *previous_mode_set |
---|
| 251 | ); |
---|
| 252 | |
---|
[067a96a] | 253 | /** |
---|
[61b8e9f] | 254 | * @brief RTEMS Task Restart |
---|
[ac7d5ef0] | 255 | * |
---|
[61b8e9f] | 256 | * This routine implements the rtems_task_restart directive. The |
---|
| 257 | * task associated with ID is restarted at its initial entry |
---|
| 258 | * point with the new argument. |
---|
[4c90eb4] | 259 | * |
---|
[61b8e9f] | 260 | * @param[in] id is the thread id |
---|
| 261 | * @param[in] arg is the thread argument |
---|
[4c90eb4] | 262 | * |
---|
[61b8e9f] | 263 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
[ac7d5ef0] | 264 | */ |
---|
| 265 | rtems_status_code rtems_task_restart( |
---|
[d3b72ca3] | 266 | rtems_id id, |
---|
[1d496f6] | 267 | uint32_t arg |
---|
[ac7d5ef0] | 268 | ); |
---|
| 269 | |
---|
[067a96a] | 270 | /** |
---|
[61b8e9f] | 271 | * @brief RTEMS Suspend Task |
---|
[ac7d5ef0] | 272 | * |
---|
[61b8e9f] | 273 | * This routine implements the rtems_task_suspend directive. The |
---|
| 274 | * SUSPENDED state is set for task associated with ID. Note that the |
---|
| 275 | * suspended state can be in addition to other waiting states. |
---|
[4c90eb4] | 276 | * |
---|
[61b8e9f] | 277 | * @param[in] id is the thread id |
---|
[4c90eb4] | 278 | * |
---|
[61b8e9f] | 279 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
| 280 | * error. Otherwise, a status code is returned indicating the |
---|
| 281 | * source of the error. |
---|
[ac7d5ef0] | 282 | */ |
---|
| 283 | rtems_status_code rtems_task_suspend( |
---|
[d3b72ca3] | 284 | rtems_id id |
---|
[ac7d5ef0] | 285 | ); |
---|
| 286 | |
---|
[067a96a] | 287 | /** |
---|
[61b8e9f] | 288 | * @brief RTEMS Resume Task |
---|
[ac7d5ef0] | 289 | * |
---|
[61b8e9f] | 290 | * This routine implements the rtems_task_resume Directive. The |
---|
| 291 | * SUSPENDED state is cleared for task associated with ID. |
---|
[4c90eb4] | 292 | * |
---|
[61b8e9f] | 293 | * @param[in] id is the thread id |
---|
[4c90eb4] | 294 | * |
---|
[61b8e9f] | 295 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
| 296 | * error. Otherwise, a status code is returned indicating the |
---|
| 297 | * source of the error. |
---|
[ac7d5ef0] | 298 | */ |
---|
| 299 | rtems_status_code rtems_task_resume( |
---|
[d3b72ca3] | 300 | rtems_id id |
---|
[ac7d5ef0] | 301 | ); |
---|
| 302 | |
---|
[067a96a] | 303 | /** |
---|
[61b8e9f] | 304 | * @brief RTEMS Set Task Priority |
---|
[ac7d5ef0] | 305 | * |
---|
[61b8e9f] | 306 | * This routine implements the rtems_task_set_priority directive. The |
---|
| 307 | * current priority of the task associated with ID is set to |
---|
| 308 | * new_priority. The former priority of that task is returned |
---|
| 309 | * in old_priority. |
---|
[4efe1955] | 310 | * |
---|
[61b8e9f] | 311 | * @param[in] id is the thread to extract |
---|
| 312 | * @param[in] new_priority is the thread to extract |
---|
| 313 | * @param[in] old_priority is the thread to extract |
---|
[4efe1955] | 314 | * |
---|
[61b8e9f] | 315 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and |
---|
| 316 | * and *old_priority filled in with the previous previous priority |
---|
[ac7d5ef0] | 317 | */ |
---|
| 318 | rtems_status_code rtems_task_set_priority( |
---|
[d3b72ca3] | 319 | rtems_id id, |
---|
[ac7d5ef0] | 320 | rtems_task_priority new_priority, |
---|
| 321 | rtems_task_priority *old_priority |
---|
| 322 | ); |
---|
| 323 | |
---|
[8123cae8] | 324 | /** |
---|
| 325 | * @brief Gets the current priority of the specified task with respect to the |
---|
| 326 | * specified scheduler instance. |
---|
| 327 | * |
---|
| 328 | * The current priority reflects temporary priority adjustments due to locking |
---|
| 329 | * protocols, the rate-monotonic period objects on some schedulers and other |
---|
| 330 | * mechanisms. |
---|
| 331 | * |
---|
| 332 | * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select |
---|
| 333 | * the executing task. |
---|
| 334 | * @param[in] scheduler_id Identifier of the scheduler instance. |
---|
| 335 | * @param[out] priority Returns the current priority of the specified task with |
---|
| 336 | * respect to the specified scheduler instance. |
---|
| 337 | * |
---|
| 338 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 339 | * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. |
---|
| 340 | * @retval RTEMS_INVALID_ADDRESS The priority parameter is @c NULL. |
---|
| 341 | * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. |
---|
| 342 | * @retval RTEMS_NOT_DEFINED The task has no priority within the specified |
---|
| 343 | * scheduler instance. This error is only possible on SMP configurations. |
---|
| 344 | * |
---|
| 345 | * @see rtems_scheduler_ident(). |
---|
| 346 | */ |
---|
| 347 | rtems_status_code rtems_task_get_priority( |
---|
| 348 | rtems_id task_id, |
---|
| 349 | rtems_id scheduler_id, |
---|
| 350 | rtems_task_priority *priority |
---|
| 351 | ); |
---|
| 352 | |
---|
[067a96a] | 353 | /** |
---|
[4c90eb4] | 354 | * @brief RTEMS Start Task |
---|
| 355 | * |
---|
| 356 | * RTEMS Task Manager |
---|
[ac7d5ef0] | 357 | * |
---|
| 358 | * This routine implements the rtems_task_start directive. The |
---|
| 359 | * starting execution point of the task associated with ID is |
---|
| 360 | * set to entry_point with the initial argument. |
---|
| 361 | */ |
---|
| 362 | rtems_status_code rtems_task_start( |
---|
[e95737c] | 363 | rtems_id id, |
---|
| 364 | rtems_task_entry entry_point, |
---|
| 365 | rtems_task_argument argument |
---|
[ac7d5ef0] | 366 | ); |
---|
| 367 | |
---|
[067a96a] | 368 | /** |
---|
[61b8e9f] | 369 | * @brief RTEMS Task Wake When |
---|
[ac7d5ef0] | 370 | * |
---|
[61b8e9f] | 371 | * This routine implements the rtems_task_wake_when directive. The |
---|
| 372 | * calling task is blocked until the current time of day is |
---|
| 373 | * equal to that indicated by time_buffer. |
---|
[4efe1955] | 374 | * |
---|
[61b8e9f] | 375 | * @param[in] time_buffer is the pointer to the time and date structure |
---|
[4efe1955] | 376 | * |
---|
[61b8e9f] | 377 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
[ac7d5ef0] | 378 | */ |
---|
| 379 | rtems_status_code rtems_task_wake_when( |
---|
| 380 | rtems_time_of_day *time_buffer |
---|
| 381 | ); |
---|
| 382 | |
---|
[067a96a] | 383 | /** |
---|
[61b8e9f] | 384 | * @brief RTEMS Task Wake After |
---|
[ac7d5ef0] | 385 | * |
---|
[61b8e9f] | 386 | * This routine implements the rtems_task_wake_after directive. The |
---|
| 387 | * calling task is blocked until the indicated number of clock |
---|
| 388 | * ticks have occurred. |
---|
[4efe1955] | 389 | * |
---|
[61b8e9f] | 390 | * @param[in] ticks is the number of ticks to wait |
---|
| 391 | * @retval RTEMS_SUCCESSFUL |
---|
[ac7d5ef0] | 392 | */ |
---|
| 393 | rtems_status_code rtems_task_wake_after( |
---|
[3a4ae6c] | 394 | rtems_interval ticks |
---|
[ac7d5ef0] | 395 | ); |
---|
| 396 | |
---|
[067a96a] | 397 | /** |
---|
| 398 | * @brief rtems_task_is_suspended |
---|
[4efe1955] | 399 | * |
---|
[e39431b] | 400 | * This directive returns a status indicating whether or not |
---|
| 401 | * the specified task is suspended. |
---|
| 402 | */ |
---|
| 403 | rtems_status_code rtems_task_is_suspended( |
---|
[d3b72ca3] | 404 | rtems_id id |
---|
[e39431b] | 405 | ); |
---|
| 406 | |
---|
[29cacfd] | 407 | /** |
---|
[0712d17] | 408 | * @brief Gets the processor affinity set of a task. |
---|
[29cacfd] | 409 | * |
---|
[0712d17] | 410 | * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the |
---|
| 411 | * executing task. |
---|
| 412 | * @param[in] cpusetsize Size of the specified affinity set buffer in |
---|
| 413 | * bytes. This value must be positive. |
---|
| 414 | * @param[out] cpuset The current processor affinity set of the task. A set |
---|
| 415 | * bit in the affinity set means that the task can execute on this processor |
---|
| 416 | * and a cleared bit means the opposite. |
---|
[29cacfd] | 417 | * |
---|
[0712d17] | 418 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 419 | * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. |
---|
| 420 | * @retval RTEMS_INVALID_ID Invalid task identifier. |
---|
| 421 | * @retval RTEMS_INVALID_NUMBER The affinity set buffer is too small for the |
---|
| 422 | * current processor affinity set of the task. |
---|
[5c332349] | 423 | */ |
---|
[29cacfd] | 424 | rtems_status_code rtems_task_get_affinity( |
---|
| 425 | rtems_id id, |
---|
| 426 | size_t cpusetsize, |
---|
[5c332349] | 427 | cpu_set_t *cpuset |
---|
[29cacfd] | 428 | ); |
---|
| 429 | |
---|
| 430 | /** |
---|
[0712d17] | 431 | * @brief Sets the processor affinity set of a task. |
---|
[29cacfd] | 432 | * |
---|
[25f5730f] | 433 | * This function will not change the scheduler of the task. The intersection |
---|
| 434 | * of the processor affinity set and the set of processors owned by the |
---|
| 435 | * scheduler of the task must be non-empty. It is not an error if the |
---|
| 436 | * processor affinity set contains processors that are not part of the set of |
---|
| 437 | * processors owned by the scheduler instance of the task. A task will simply |
---|
| 438 | * not run under normal circumstances on these processors since the scheduler |
---|
| 439 | * ignores them. Some locking protocols may temporarily use processors that |
---|
| 440 | * are not included in the processor affinity set of the task. It is also not |
---|
| 441 | * an error if the processor affinity set contains processors that are not part |
---|
| 442 | * of the system. |
---|
| 443 | * |
---|
[0712d17] | 444 | * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the |
---|
| 445 | * executing task. |
---|
| 446 | * @param[in] cpusetsize Size of the specified affinity set buffer in |
---|
| 447 | * bytes. This value must be positive. |
---|
| 448 | * @param[in] cpuset The new processor affinity set for the task. A set bit in |
---|
| 449 | * the affinity set means that the task can execute on this processor and a |
---|
| 450 | * cleared bit means the opposite. |
---|
[29cacfd] | 451 | * |
---|
[0712d17] | 452 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 453 | * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. |
---|
| 454 | * @retval RTEMS_INVALID_ID Invalid task identifier. |
---|
| 455 | * @retval RTEMS_INVALID_NUMBER Invalid processor affinity set. |
---|
[5c332349] | 456 | */ |
---|
[29cacfd] | 457 | rtems_status_code rtems_task_set_affinity( |
---|
[561c7b2] | 458 | rtems_id id, |
---|
| 459 | size_t cpusetsize, |
---|
| 460 | const cpu_set_t *cpuset |
---|
[29cacfd] | 461 | ); |
---|
| 462 | |
---|
[27270b0d] | 463 | /** |
---|
| 464 | * @brief Gets the scheduler of a task. |
---|
| 465 | * |
---|
[e5274df] | 466 | * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select |
---|
| 467 | * the executing task. |
---|
[05ca53d] | 468 | * @param[out] scheduler_id Identifier of the scheduler instance. |
---|
[27270b0d] | 469 | * |
---|
| 470 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 471 | * @retval RTEMS_INVALID_ADDRESS The @a scheduler_id parameter is @c NULL. |
---|
| 472 | * @retval RTEMS_INVALID_ID Invalid task identifier. |
---|
| 473 | */ |
---|
| 474 | rtems_status_code rtems_task_get_scheduler( |
---|
[e5274df] | 475 | rtems_id task_id, |
---|
[27270b0d] | 476 | rtems_id *scheduler_id |
---|
| 477 | ); |
---|
| 478 | |
---|
| 479 | /** |
---|
[c0bd006] | 480 | * @brief Sets the scheduler instance of a task. |
---|
[27270b0d] | 481 | * |
---|
[c0bd006] | 482 | * Initially, the scheduler instance of a task is set to the scheduler instance |
---|
| 483 | * of the task that created it. This directive allows to move a task from its |
---|
| 484 | * current scheduler instance to another specified by the scheduler identifier. |
---|
[f830029] | 485 | * |
---|
[e5274df] | 486 | * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select |
---|
[c0bd006] | 487 | * the executing task. |
---|
| 488 | * @param[in] scheduler_id Identifier of the scheduler instance. |
---|
| 489 | * @param[in] priority The task priority with respect to the new scheduler |
---|
| 490 | * instance. The real and initial priority of the task is set to this value. |
---|
| 491 | * The initial priority is used by rtems_task_restart() for example. |
---|
[27270b0d] | 492 | * |
---|
| 493 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
[c0bd006] | 494 | * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. |
---|
[27270b0d] | 495 | * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. |
---|
[c0bd006] | 496 | * @retval RTEMS_INVALID_PRIORITY Invalid priority. |
---|
| 497 | * @retval RTEMS_RESOURCE_IN_USE The task owns resources which deny a scheduler |
---|
| 498 | * change. |
---|
[27270b0d] | 499 | * |
---|
| 500 | * @see rtems_scheduler_ident(). |
---|
| 501 | */ |
---|
| 502 | rtems_status_code rtems_task_set_scheduler( |
---|
[c0bd006] | 503 | rtems_id task_id, |
---|
| 504 | rtems_id scheduler_id, |
---|
| 505 | rtems_task_priority priority |
---|
[27270b0d] | 506 | ); |
---|
| 507 | |
---|
[067a96a] | 508 | /** |
---|
[205dbb9d] | 509 | * @brief RTEMS Get Self Task Id |
---|
[23a0607e] | 510 | * |
---|
| 511 | * This directive returns the ID of the currently executing task. |
---|
| 512 | */ |
---|
| 513 | rtems_id rtems_task_self(void); |
---|
| 514 | |
---|
[d271c3bb] | 515 | /** |
---|
| 516 | * @brief Task visitor. |
---|
| 517 | * |
---|
| 518 | * @param[in] tcb The task control block. |
---|
| 519 | * @param[in] arg The visitor argument. |
---|
| 520 | * |
---|
| 521 | * @retval true Stop the iteration. |
---|
| 522 | * @retval false Otherwise. |
---|
| 523 | * |
---|
| 524 | * @see rtems_task_iterate(). |
---|
| 525 | */ |
---|
| 526 | typedef bool ( *rtems_task_visitor )( rtems_tcb *tcb, void *arg ); |
---|
| 527 | |
---|
| 528 | /** |
---|
| 529 | * @brief Iterates over all tasks in the system. |
---|
| 530 | * |
---|
| 531 | * This operation covers all tasks of all APIs. |
---|
| 532 | * |
---|
| 533 | * Must be called from task context. This operation obtains and releases the |
---|
| 534 | * objects allocator lock. The task visitor is called while owning the objects |
---|
| 535 | * allocator lock. It is possible to perform blocking operations in the task |
---|
| 536 | * visitor, however, take care that no deadlocks via the object allocator lock |
---|
| 537 | * can occur. |
---|
| 538 | * |
---|
| 539 | * @param[in] visitor The task visitor. |
---|
| 540 | * @param[in] arg The visitor argument. |
---|
| 541 | */ |
---|
| 542 | void rtems_task_iterate( |
---|
| 543 | rtems_task_visitor visitor, |
---|
| 544 | void *arg |
---|
| 545 | ); |
---|
| 546 | |
---|
[b427a92] | 547 | /** |
---|
| 548 | * @brief Identifies a scheduler by its name. |
---|
| 549 | * |
---|
| 550 | * The scheduler name is determined by the scheduler configuration. |
---|
| 551 | * |
---|
| 552 | * @param[in] name The scheduler name. |
---|
| 553 | * @param[out] id The scheduler identifier associated with the name. |
---|
| 554 | * |
---|
| 555 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 556 | * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. |
---|
| 557 | * @retval RTEMS_INVALID_NAME Invalid scheduler name. |
---|
| 558 | */ |
---|
| 559 | rtems_status_code rtems_scheduler_ident( |
---|
| 560 | rtems_name name, |
---|
| 561 | rtems_id *id |
---|
| 562 | ); |
---|
| 563 | |
---|
[548d65a5] | 564 | /** |
---|
| 565 | * @brief Identifies a scheduler by a processor index. |
---|
| 566 | * |
---|
| 567 | * @param[in] cpu_index The processor index. |
---|
| 568 | * @param[out] id The scheduler identifier associated with the processor index. |
---|
| 569 | * |
---|
| 570 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 571 | * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. |
---|
| 572 | * @retval RTEMS_INVALID_NAME Invalid processor index. |
---|
| 573 | * @retval RTEMS_INCORRECT_STATE The processor index is valid, however, this |
---|
| 574 | * processor is not owned by a scheduler. |
---|
| 575 | */ |
---|
| 576 | rtems_status_code rtems_scheduler_ident_by_processor( |
---|
| 577 | uint32_t cpu_index, |
---|
| 578 | rtems_id *id |
---|
| 579 | ); |
---|
| 580 | |
---|
[ecabd384] | 581 | /** |
---|
| 582 | * @brief Identifies a scheduler by a processor set. |
---|
| 583 | * |
---|
| 584 | * The scheduler is selected according to the highest numbered online processor |
---|
| 585 | * in the specified processor set. |
---|
| 586 | * |
---|
| 587 | * @param[in] cpusetsize Size of the specified processor set buffer in |
---|
| 588 | * bytes. This value must be positive. |
---|
| 589 | * @param[out] cpuset The processor set to identify the scheduler. |
---|
| 590 | * @param[out] id The scheduler identifier associated with the processor set. |
---|
| 591 | * |
---|
| 592 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 593 | * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. |
---|
| 594 | * @retval RTEMS_INVALID_SIZE Invalid processor set size. |
---|
| 595 | * @retval RTEMS_INVALID_NAME The processor set contains no online processor. |
---|
| 596 | * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the |
---|
| 597 | * highest numbered online processor in the specified processor set is not |
---|
| 598 | * owned by a scheduler. |
---|
| 599 | */ |
---|
| 600 | rtems_status_code rtems_scheduler_ident_by_processor_set( |
---|
| 601 | size_t cpusetsize, |
---|
| 602 | const cpu_set_t *cpuset, |
---|
| 603 | rtems_id *id |
---|
| 604 | ); |
---|
| 605 | |
---|
[1b67535d] | 606 | /** |
---|
[05ca53d] | 607 | * @brief Gets the set of processors owned by the specified scheduler instance. |
---|
[1b67535d] | 608 | * |
---|
[05ca53d] | 609 | * @param[in] scheduler_id Identifier of the scheduler instance. |
---|
[1b67535d] | 610 | * @param[in] cpusetsize Size of the specified processor set buffer in |
---|
| 611 | * bytes. This value must be positive. |
---|
| 612 | * @param[out] cpuset The processor set owned by the scheduler. A set bit in |
---|
| 613 | * the processor set means that this processor is owned by the scheduler and a |
---|
| 614 | * cleared bit means the opposite. |
---|
| 615 | * |
---|
| 616 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 617 | * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. |
---|
[05ca53d] | 618 | * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. |
---|
[1b67535d] | 619 | * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the |
---|
| 620 | * set of processors owned by the scheduler. |
---|
| 621 | */ |
---|
| 622 | rtems_status_code rtems_scheduler_get_processor_set( |
---|
| 623 | rtems_id scheduler_id, |
---|
| 624 | size_t cpusetsize, |
---|
| 625 | cpu_set_t *cpuset |
---|
| 626 | ); |
---|
| 627 | |
---|
[05ca53d] | 628 | /** |
---|
| 629 | * @brief Adds a processor to the set of processors owned by the specified |
---|
| 630 | * scheduler instance. |
---|
| 631 | * |
---|
| 632 | * Must be called from task context. This operation obtains and releases the |
---|
| 633 | * objects allocator lock. |
---|
| 634 | * |
---|
| 635 | * @param[in] scheduler_id Identifier of the scheduler instance. |
---|
| 636 | * @param[in] cpu_index Index of the processor to add. |
---|
| 637 | * |
---|
| 638 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 639 | * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. |
---|
| 640 | * @retval RTEMS_NOT_CONFIGURED The processor is not configured to be used by |
---|
| 641 | * the application. |
---|
| 642 | * @retval RTEMS_INCORRECT_STATE The processor is configured to be used by |
---|
| 643 | * the application, however, it is not online. |
---|
| 644 | * @retval RTEMS_RESOURCE_IN_USE The processor is already assigned to a |
---|
| 645 | * scheduler instance. |
---|
| 646 | */ |
---|
| 647 | rtems_status_code rtems_scheduler_add_processor( |
---|
| 648 | rtems_id scheduler_id, |
---|
| 649 | uint32_t cpu_index |
---|
| 650 | ); |
---|
| 651 | |
---|
| 652 | /** |
---|
| 653 | * @brief Removes a processor from set of processors owned by the specified |
---|
| 654 | * scheduler instance. |
---|
| 655 | * |
---|
| 656 | * Must be called from task context. This operation obtains and releases the |
---|
| 657 | * objects allocator lock. Removing a processor from a scheduler is a complex |
---|
| 658 | * operation that involves all tasks of the system. |
---|
| 659 | * |
---|
| 660 | * @param[in] scheduler_id Identifier of the scheduler instance. |
---|
| 661 | * @param[in] cpu_index Index of the processor to add. |
---|
| 662 | * |
---|
| 663 | * @retval RTEMS_SUCCESSFUL Successful operation. |
---|
| 664 | * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. |
---|
| 665 | * @retval RTEMS_INVALID_NUMBER The processor is not owned by the specified |
---|
| 666 | * scheduler instance. |
---|
| 667 | * @retval RTEMS_RESOURCE_IN_USE The set of processors owned by the specified |
---|
| 668 | * scheduler instance would be empty after the processor removal and there |
---|
| 669 | * exists a non-idle task that uses this scheduler instance as its home |
---|
| 670 | * scheduler instance. |
---|
| 671 | */ |
---|
| 672 | rtems_status_code rtems_scheduler_remove_processor( |
---|
| 673 | rtems_id scheduler_id, |
---|
| 674 | uint32_t cpu_index |
---|
| 675 | ); |
---|
| 676 | |
---|
[c404828] | 677 | /**@}*/ |
---|
| 678 | |
---|
[067a96a] | 679 | /** |
---|
[c404828] | 680 | * This is the API specific information required by each thread for |
---|
| 681 | * the RTEMS API to function correctly. |
---|
[7f6a24ab] | 682 | * |
---|
| 683 | */ |
---|
[c404828] | 684 | typedef struct { |
---|
| 685 | /** This field contains the event control for this task. */ |
---|
| 686 | Event_Control Event; |
---|
| 687 | /** This field contains the system event control for this task. */ |
---|
| 688 | Event_Control System_event; |
---|
| 689 | /** This field contains the Classic API Signal information for this task. */ |
---|
| 690 | ASR_Information Signal; |
---|
[6fd1bdb7] | 691 | |
---|
| 692 | /** |
---|
| 693 | * @brief Signal post-switch action in case signals are pending. |
---|
| 694 | */ |
---|
| 695 | Thread_Action Signal_action; |
---|
[c404828] | 696 | } RTEMS_API_Control; |
---|
[3a4ae6c] | 697 | |
---|
[b929b39e] | 698 | /** |
---|
| 699 | * @brief _RTEMS_tasks_Initialize_user_tasks_body |
---|
| 700 | * |
---|
| 701 | * This routine creates and starts all configured user |
---|
| 702 | * initialization threads. |
---|
| 703 | * |
---|
| 704 | * Input parameters: NONE |
---|
| 705 | * |
---|
| 706 | * Output parameters: NONE |
---|
[4efe1955] | 707 | * |
---|
| 708 | * RTEMS Task Manager |
---|
[b929b39e] | 709 | */ |
---|
| 710 | |
---|
| 711 | extern void _RTEMS_tasks_Initialize_user_tasks_body( void ); |
---|
| 712 | |
---|
[ac7d5ef0] | 713 | #ifdef __cplusplus |
---|
| 714 | } |
---|
| 715 | #endif |
---|
| 716 | |
---|
| 717 | #endif |
---|
| 718 | /* end of include file */ |
---|