RTEMS CPU Kit with SuperCore  4.11.2
threadqimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2014.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_THREADQIMPL_H
20 #define _RTEMS_SCORE_THREADQIMPL_H
21 
22 #include <rtems/score/threadq.h>
23 #include <rtems/score/chainimpl.h>
24 #include <rtems/score/rbtreeimpl.h>
25 #include <rtems/score/thread.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
36 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(
37  Thread_queue_Control *the_thread_queue,
38  ISR_lock_Context *lock_context
39 )
40 {
41  _ISR_lock_Acquire( &the_thread_queue->Lock, lock_context );
42 }
43 
44 RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(
45  Thread_queue_Control *the_thread_queue,
46  ISR_lock_Context *lock_context
47 )
48 {
49  _ISR_lock_ISR_disable( lock_context );
50  _Thread_queue_Acquire_critical( the_thread_queue, lock_context );
51 }
52 
53 RTEMS_INLINE_ROUTINE void _Thread_queue_Release(
54  Thread_queue_Control *the_thread_queue,
55  ISR_lock_Context *lock_context
56 )
57 {
58  _ISR_lock_Release_and_ISR_enable( &the_thread_queue->Lock, lock_context );
59 }
60 
65 typedef void ( *Thread_queue_Flush_callout )(
67  );
68 
81  Thread_queue_Control *the_thread_queue
82 );
83 
143  Thread_queue_Control *the_thread_queue,
144  Thread_Control *the_thread,
145  States_Control state,
146  Watchdog_Interval timeout,
147  uint32_t timeout_code,
148  ISR_lock_Context *lock_context
149 );
150 
156  Thread_queue_Control *the_thread_queue,
157  Thread_Control *the_thread,
158  States_Control state,
159  Watchdog_Interval timeout,
160  uint32_t timeout_code
161 )
162 {
163  ISR_lock_Context lock_context;
164 
165  _Thread_queue_Acquire( the_thread_queue, &lock_context );
167  the_thread_queue,
168  the_thread,
169  state,
170  timeout,
171  timeout_code,
172  &lock_context
173  );
174 }
175 
187  Thread_queue_Control *the_thread_queue,
188  Thread_Control *the_thread
189 );
190 
204  Thread_queue_Control *the_thread_queue,
205  Thread_Control *the_thread,
206  ISR_lock_Context *lock_context
207 );
208 
253  Thread_queue_Control *the_thread_queue,
254  Thread_Control *the_thread,
255  ISR_lock_Context *lock_context
256 );
257 
267 void _Thread_queue_Extract( Thread_Control *the_thread );
268 
277  Thread_Control *the_thread
278 );
279 
294  Thread_queue_Control *the_thread_queue
295 )
296 {
297  return ( *the_thread_queue->operations->first )( the_thread_queue );
298 }
299 
311  Thread_queue_Control *the_thread_queue
312 );
313 
327  Thread_queue_Control *the_thread_queue,
328  Thread_queue_Flush_callout remote_extract_callout,
329  uint32_t status
330 );
331 
343  Thread_queue_Control *the_thread_queue,
344  Thread_queue_Disciplines the_discipline
345 );
346 
347 #if defined(RTEMS_SMP)
348  #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
349  .Queues = { \
350  .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queues.Fifo ) \
351  }, \
352  .operations = &_Thread_queue_Operations_FIFO, \
353  .Lock = ISR_LOCK_INITIALIZER( name ) \
354  }
355 
356  #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
357  .Queues = { \
358  .Priority = RBTREE_INITIALIZER_EMPTY( designator.Queues.Priority ) \
359  }, \
360  .operations = &_Thread_queue_Operations_priority, \
361  .Lock = ISR_LOCK_INITIALIZER( name ) \
362  }
363 #else
364  #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \
365  .Queues = { \
366  .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queues.Fifo ) \
367  }, \
368  .operations = &_Thread_queue_Operations_FIFO \
369  }
370 
371  #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \
372  .Queues = { \
373  .Priority = RBTREE_INITIALIZER_EMPTY( designator.Queues.Priority ) \
374  }, \
375  .operations = &_Thread_queue_Operations_priority \
376  }
377 #endif
378 
379 RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(
380  Thread_queue_Control *the_thread_queue
381 )
382 {
383  _ISR_lock_Destroy( &the_thread_queue->Lock );
384 }
385 
397  const RBTree_Node *left,
398  const RBTree_Node *right
399 );
400 
401 extern const Thread_queue_Operations _Thread_queue_Operations_default;
402 
403 extern const Thread_queue_Operations _Thread_queue_Operations_FIFO;
404 
405 extern const Thread_queue_Operations _Thread_queue_Operations_priority;
406 
409 #ifdef __cplusplus
410 }
411 #endif
412 
413 #endif
414 /* end of include file */
const Thread_queue_Operations * operations
The operations for this thread queue.
Definition: threadq.h:185
void _Thread_queue_Unblock_critical(Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, ISR_lock_Context *lock_context)
Unblocks the thread which was on the thread queue before.
Definition: threadqenqueue.c:116
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:257
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
void _Thread_queue_Extract(Thread_Control *the_thread)
Extracts thread from thread queue.
Definition: threadqenqueue.c:162
Thread_Control * _Thread_queue_Dequeue(Thread_queue_Control *the_thread_queue)
Gets a pointer to a thread waiting on the_thread_queue.
Definition: threadqenqueue.c:181
void _Thread_queue_Extract_locked(Thread_queue_Control *the_thread_queue, Thread_Control *the_thread)
Extracts the thread from the thread queue, restores the default wait operations and restores the defa...
Definition: threadqenqueue.c:104
This is the structure used to manage sets of tasks which are blocked waiting to acquire a resource...
Definition: threadq.h:171
RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, States_Control state, Watchdog_Interval timeout, uint32_t timeout_code)
Acquires the thread queue lock and calls _Thread_queue_Enqueue_critical().
Definition: threadqimpl.h:155
void _Thread_queue_Flush(Thread_queue_Control *the_thread_queue, Thread_queue_Flush_callout remote_extract_callout, uint32_t status)
Unblocks all threads blocked on the_thread_queue.
Definition: threadqflush.c:24
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:155
Constants and Structures Needed to Declare a Thread Queue.
long RBTree_Compare_result
Integer type for compare results.
Definition: rbtree.h:99
Thread queue operations.
Definition: threadq.h:118
Constants and Structures Related with the Thread Control Block.
void _Thread_queue_Enqueue_critical(Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, States_Control state, Watchdog_Interval timeout, uint32_t timeout_code, ISR_lock_Context *lock_context)
Blocks the thread and places it on the thread queue.
Definition: threadqenqueue.c:48
void _Thread_queue_Extract_critical(Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, ISR_lock_Context *lock_context)
Extracts the thread from the thread queue and unblocks it.
Definition: threadqenqueue.c:152
RBTree_Compare_result _Thread_queue_Compare_priority(const RBTree_Node *left, const RBTree_Node *right)
Compare two thread&#39;s priority for RBTree Insertion.
Definition: threadq.c:25
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:337
This structure defines the Thread Control Block (TCB).
Definition: thread.h:671
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
Definition: isrlock.h:230
Chain Handler API.
Inlined Routines Associated with Red-Black Trees.
void _Thread_queue_Initialize(Thread_queue_Control *the_thread_queue, Thread_queue_Disciplines the_discipline)
Initialize the_thread_queue.
Definition: threadq.c:46
uint32_t States_Control
The following type defines the control block used to manage a thread&#39;s state.
Definition: states.h:41
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdog.h:47
Thread_Control * _Thread_queue_First(Thread_queue_Control *the_thread_queue)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqfirst.c:23
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
RTEMS_INLINE_ROUTINE Thread_Control * _Thread_queue_First_locked(Thread_queue_Control *the_thread_queue)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqimpl.h:293
void _Thread_queue_Extract_with_proxy(Thread_Control *the_thread)
Extracts the_thread from the_thread_queue.
Definition: threadqextractwithproxy.c:31
This is used to manage each element (node) which is placed on a RBT.
Definition: rbtree.h:75
#define _ISR_lock_Destroy(_lock)
Destroys an ISR lock.
Definition: isrlock.h:181
Thread_queue_Disciplines
The following enumerated type details all of the disciplines supported by the Thread Queue Handler...
Definition: threadq.h:162
void(* Thread_queue_Flush_callout)(Thread_Control *)
The following type defines the callout used when a remote task is extracted from a local thread queue...
Definition: threadqimpl.h:65