[ac7d5ef0] | 1 | /* threadq.h |
---|
| 2 | * |
---|
| 3 | * This include file contains all the constants and structures associated |
---|
| 4 | * with the manipulation of objects. |
---|
| 5 | * |
---|
[60b791ad] | 6 | * COPYRIGHT (c) 1989-1998. |
---|
[ac7d5ef0] | 7 | * On-Line Applications Research Corporation (OAR). |
---|
[03f2154e] | 8 | * Copyright assigned to U.S. Government, 1994. |
---|
[ac7d5ef0] | 9 | * |
---|
[98e4ebf5] | 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 12 | * http://www.OARcorp.com/rtems/license.html. |
---|
[ac7d5ef0] | 13 | * |
---|
| 14 | * $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
[3a4ae6c] | 17 | #ifndef __THREAD_QUEUE_h |
---|
| 18 | #define __THREAD_QUEUE_h |
---|
[ac7d5ef0] | 19 | |
---|
| 20 | #ifdef __cplusplus |
---|
| 21 | extern "C" { |
---|
| 22 | #endif |
---|
| 23 | |
---|
[5e9b32b] | 24 | #include <rtems/score/tqdata.h> |
---|
[ac7d5ef0] | 25 | |
---|
[5e9b32b] | 26 | #include <rtems/score/object.h> |
---|
| 27 | #include <rtems/score/thread.h> |
---|
| 28 | #include <rtems/score/watchdog.h> |
---|
| 29 | |
---|
| 30 | /* |
---|
| 31 | * Constant for indefinite wait. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #define THREAD_QUEUE_WAIT_FOREVER WATCHDOG_NO_TIMEOUT |
---|
[ac7d5ef0] | 35 | |
---|
| 36 | /* |
---|
| 37 | * The following type defines the callout used when a remote task |
---|
| 38 | * is extracted from a local thread queue. |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | typedef void ( *Thread_queue_Flush_callout )( |
---|
| 42 | Thread_Control * |
---|
| 43 | ); |
---|
| 44 | |
---|
[7f6a24ab] | 45 | /* |
---|
| 46 | * The following type defines the callout used when a local task |
---|
| 47 | * is extracted from a remote thread queue (i.e. it's proxy must |
---|
| 48 | * extracted from the remote queue). |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | typedef void ( *Thread_queue_Extract_callout )( |
---|
| 52 | Thread_Control * |
---|
| 53 | ); |
---|
| 54 | |
---|
[c627b2a3] | 55 | SCORE_EXTERN Thread_queue_Extract_callout |
---|
[7f6a24ab] | 56 | _Thread_queue_Extract_table[ OBJECTS_CLASSES_LAST + 1 ]; |
---|
| 57 | |
---|
[ac7d5ef0] | 58 | /* |
---|
| 59 | * _Thread_queue_Dequeue |
---|
| 60 | * |
---|
| 61 | * DESCRIPTION: |
---|
| 62 | * |
---|
| 63 | * This function returns a pointer to a thread waiting on |
---|
| 64 | * the_thread_queue. The selection of this thread is based on |
---|
| 65 | * the discipline of the_thread_queue. If no threads are waiting |
---|
| 66 | * on the_thread_queue, then NULL is returned. |
---|
| 67 | */ |
---|
| 68 | |
---|
| 69 | Thread_Control *_Thread_queue_Dequeue( |
---|
| 70 | Thread_queue_Control *the_thread_queue |
---|
| 71 | ); |
---|
| 72 | |
---|
| 73 | /* |
---|
| 74 | * _Thread_queue_Enqueue |
---|
| 75 | * |
---|
| 76 | * DESCRIPTION: |
---|
| 77 | * |
---|
| 78 | * This routine enqueues the currently executing thread on |
---|
| 79 | * the_thread_queue with an optional timeout. |
---|
| 80 | */ |
---|
| 81 | |
---|
| 82 | void _Thread_queue_Enqueue( |
---|
| 83 | Thread_queue_Control *the_thread_queue, |
---|
[3a4ae6c] | 84 | Watchdog_Interval timeout |
---|
[ac7d5ef0] | 85 | ); |
---|
| 86 | |
---|
| 87 | /* |
---|
| 88 | * _Thread_queue_Extract |
---|
| 89 | * |
---|
| 90 | * DESCRIPTION: |
---|
| 91 | * |
---|
| 92 | * This routine removes the_thread from the_thread_queue |
---|
| 93 | * and cancels any timeouts associated with this blocking. |
---|
| 94 | */ |
---|
| 95 | |
---|
| 96 | void _Thread_queue_Extract( |
---|
| 97 | Thread_queue_Control *the_thread_queue, |
---|
| 98 | Thread_Control *the_thread |
---|
| 99 | ); |
---|
| 100 | |
---|
[7f6a24ab] | 101 | /* |
---|
| 102 | * _Thread_queue_Extract_with_proxy |
---|
| 103 | * |
---|
| 104 | * DESCRIPTION: |
---|
| 105 | * |
---|
| 106 | * This routine extracts the_thread from the_thread_queue |
---|
| 107 | * and insures that if there is a proxy for this task on |
---|
| 108 | * another node, it is also dealt with. |
---|
| 109 | */ |
---|
| 110 | |
---|
| 111 | boolean _Thread_queue_Extract_with_proxy( |
---|
| 112 | Thread_Control *the_thread |
---|
| 113 | ); |
---|
| 114 | |
---|
[ac7d5ef0] | 115 | /* |
---|
| 116 | * _Thread_queue_First |
---|
| 117 | * |
---|
| 118 | * DESCRIPTION: |
---|
| 119 | * |
---|
| 120 | * This function returns a pointer to the "first" thread |
---|
| 121 | * on the_thread_queue. The "first" thread is selected |
---|
| 122 | * based on the discipline of the_thread_queue. |
---|
| 123 | */ |
---|
| 124 | |
---|
| 125 | Thread_Control *_Thread_queue_First( |
---|
| 126 | Thread_queue_Control *the_thread_queue |
---|
| 127 | ); |
---|
| 128 | |
---|
| 129 | /* |
---|
| 130 | * _Thread_queue_Flush |
---|
| 131 | * |
---|
| 132 | * DESCRIPTION: |
---|
| 133 | * |
---|
| 134 | * This routine unblocks all threads blocked on the_thread_queue |
---|
| 135 | * and cancels any associated timeouts. |
---|
| 136 | */ |
---|
| 137 | |
---|
| 138 | void _Thread_queue_Flush( |
---|
| 139 | Thread_queue_Control *the_thread_queue, |
---|
[3a4ae6c] | 140 | Thread_queue_Flush_callout remote_extract_callout, |
---|
| 141 | unsigned32 status |
---|
[ac7d5ef0] | 142 | ); |
---|
| 143 | |
---|
| 144 | /* |
---|
| 145 | * _Thread_queue_Initialize |
---|
| 146 | * |
---|
| 147 | * DESCRIPTION: |
---|
| 148 | * |
---|
| 149 | * This routine initializes the_thread_queue based on the |
---|
| 150 | * discipline indicated in attribute_set. The state set on |
---|
| 151 | * threads which block on the_thread_queue is state. |
---|
| 152 | */ |
---|
| 153 | |
---|
| 154 | void _Thread_queue_Initialize( |
---|
[7f6a24ab] | 155 | Thread_queue_Control *the_thread_queue, |
---|
| 156 | Objects_Classes the_class, |
---|
| 157 | Thread_queue_Disciplines the_discipline, |
---|
| 158 | States_Control state, |
---|
[3a4ae6c] | 159 | Thread_queue_Extract_callout proxy_extract_callout, |
---|
| 160 | unsigned32 timeout_status |
---|
[ac7d5ef0] | 161 | ); |
---|
| 162 | |
---|
| 163 | /* |
---|
| 164 | * _Thread_queue_Dequeue_priority |
---|
| 165 | * |
---|
| 166 | * DESCRIPTION: |
---|
| 167 | * |
---|
| 168 | * This function returns a pointer to the highest priority |
---|
| 169 | * thread waiting on the_thread_queue. If no threads are waiting |
---|
| 170 | * on the_thread_queue, then NULL is returned. |
---|
| 171 | */ |
---|
| 172 | |
---|
| 173 | Thread_Control *_Thread_queue_Dequeue_priority( |
---|
| 174 | Thread_queue_Control *the_thread_queue |
---|
| 175 | ); |
---|
| 176 | |
---|
| 177 | /* |
---|
| 178 | * _Thread_queue_Enqueue_priority |
---|
| 179 | * |
---|
| 180 | * DESCRIPTION: |
---|
| 181 | * |
---|
| 182 | * This routine enqueues the currently executing thread on |
---|
| 183 | * the_thread_queue with an optional timeout using the |
---|
| 184 | * priority discipline. |
---|
| 185 | */ |
---|
| 186 | |
---|
| 187 | void _Thread_queue_Enqueue_priority( |
---|
| 188 | Thread_queue_Control *the_thread_queue, |
---|
| 189 | Thread_Control *the_thread, |
---|
[3a4ae6c] | 190 | Watchdog_Interval timeout |
---|
[ac7d5ef0] | 191 | ); |
---|
| 192 | |
---|
| 193 | /* |
---|
| 194 | * _Thread_queue_Extract_priority |
---|
| 195 | * |
---|
| 196 | * DESCRIPTION: |
---|
| 197 | * |
---|
| 198 | * This routine removes the_thread from the_thread_queue |
---|
| 199 | * and cancels any timeouts associated with this blocking. |
---|
| 200 | */ |
---|
| 201 | |
---|
| 202 | void _Thread_queue_Extract_priority( |
---|
| 203 | Thread_queue_Control *the_thread_queue, |
---|
| 204 | Thread_Control *the_thread |
---|
| 205 | ); |
---|
| 206 | |
---|
| 207 | /* |
---|
| 208 | * _Thread_queue_First_priority |
---|
| 209 | * |
---|
| 210 | * DESCRIPTION: |
---|
| 211 | * |
---|
| 212 | * This function returns a pointer to the "first" thread |
---|
| 213 | * on the_thread_queue. The "first" thread is the highest |
---|
| 214 | * priority thread waiting on the_thread_queue. |
---|
| 215 | */ |
---|
| 216 | |
---|
| 217 | Thread_Control *_Thread_queue_First_priority( |
---|
| 218 | Thread_queue_Control *the_thread_queue |
---|
| 219 | ); |
---|
| 220 | |
---|
| 221 | /* |
---|
| 222 | * _Thread_queue_Dequeue_FIFO |
---|
| 223 | * |
---|
| 224 | * DESCRIPTION: |
---|
| 225 | * |
---|
| 226 | * This function returns a pointer to the thread which has |
---|
| 227 | * been waiting the longest on the_thread_queue. If no |
---|
| 228 | * threads are waiting on the_thread_queue, then NULL is returned. |
---|
| 229 | */ |
---|
| 230 | |
---|
| 231 | Thread_Control *_Thread_queue_Dequeue_fifo( |
---|
| 232 | Thread_queue_Control *the_thread_queue |
---|
| 233 | ); |
---|
| 234 | |
---|
| 235 | /* |
---|
| 236 | * _Thread_queue_Enqueue_FIFO |
---|
| 237 | * |
---|
| 238 | * DESCRIPTION: |
---|
| 239 | * |
---|
| 240 | * This routine enqueues the currently executing thread on |
---|
| 241 | * the_thread_queue with an optional timeout using the |
---|
[3a4ae6c] | 242 | * FIFO discipline. |
---|
[ac7d5ef0] | 243 | */ |
---|
| 244 | |
---|
| 245 | void _Thread_queue_Enqueue_fifo( |
---|
| 246 | Thread_queue_Control *the_thread_queue, |
---|
| 247 | Thread_Control *the_thread, |
---|
[3a4ae6c] | 248 | Watchdog_Interval timeout |
---|
[ac7d5ef0] | 249 | ); |
---|
| 250 | |
---|
| 251 | /* |
---|
| 252 | * _Thread_queue_Extract_FIFO |
---|
| 253 | * |
---|
| 254 | * DESCRIPTION: |
---|
| 255 | * |
---|
| 256 | * This routine removes the_thread from the_thread_queue |
---|
| 257 | * and cancels any timeouts associated with this blocking. |
---|
| 258 | */ |
---|
| 259 | |
---|
| 260 | void _Thread_queue_Extract_fifo( |
---|
| 261 | Thread_queue_Control *the_thread_queue, |
---|
| 262 | Thread_Control *the_thread |
---|
| 263 | ); |
---|
| 264 | |
---|
| 265 | /* |
---|
| 266 | * _Thread_queue_First_FIFO |
---|
| 267 | * |
---|
| 268 | * DESCRIPTION: |
---|
| 269 | * |
---|
| 270 | * This function returns a pointer to the "first" thread |
---|
| 271 | * on the_thread_queue. The first thread is the thread |
---|
| 272 | * which has been waiting longest on the_thread_queue. |
---|
| 273 | */ |
---|
| 274 | |
---|
| 275 | Thread_Control *_Thread_queue_First_fifo( |
---|
| 276 | Thread_queue_Control *the_thread_queue |
---|
| 277 | ); |
---|
| 278 | |
---|
| 279 | /* |
---|
| 280 | * _Thread_queue_timeout |
---|
| 281 | * |
---|
| 282 | * DESCRIPTION: |
---|
| 283 | * |
---|
| 284 | * This routine is invoked when a task's request has not |
---|
| 285 | * been satisfied after the timeout interval specified to |
---|
| 286 | * enqueue. The task represented by ID will be unblocked and |
---|
| 287 | * its status code will be set in it's control block to indicate |
---|
| 288 | * that a timeout has occurred. |
---|
| 289 | */ |
---|
| 290 | |
---|
| 291 | void _Thread_queue_Timeout ( |
---|
| 292 | Objects_Id id, |
---|
| 293 | void *ignored |
---|
| 294 | ); |
---|
| 295 | |
---|
| 296 | #ifdef __cplusplus |
---|
| 297 | } |
---|
| 298 | #endif |
---|
| 299 | |
---|
| 300 | #endif |
---|
| 301 | /* end of include file */ |
---|