21#ifndef _RTEMS_SCORE_THREADQIMPL_H
22#define _RTEMS_SCORE_THREADQIMPL_H
29#include <rtems/score/status.h>
33#if defined(RTEMS_DEBUG)
47#define THREAD_QUEUE_LINK_OF_PATH_NODE( node ) \
48 RTEMS_CONTAINER_OF( node, Thread_queue_Link, Path_node );
55#if !defined(RTEMS_SMP)
62 unsigned int reserved[2];
156#if defined(RTEMS_DEBUG)
157 memset( queue_context, 0x7f,
sizeof( *queue_context ) );
158#if defined(RTEMS_SMP)
164 (void) queue_context;
283 const struct timespec *abstime
303 const struct timespec *abstime
397#define _Thread_queue_Context_ISR_disable( queue_context, level ) \
399 _ISR_Local_disable( level ); \
400 _ISR_lock_ISR_disable_profile( \
401 &( queue_context )->Lock_context.Lock_context \
447#if defined(RTEMS_MULTIPROCESSING)
450 Thread_queue_MP_callout mp_callout
453 queue_context->mp_callout = mp_callout;
456#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \
458 (void) queue_context; \
462#if defined(RTEMS_SMP)
469 Thread_queue_Gate *gate
472 _Atomic_Store_uint( &gate->go_ahead, 0, ATOMIC_ORDER_RELAXED );
483 Thread_queue_Gate *gate
495 Thread_queue_Gate *gate
498 _Atomic_Store_uint( &gate->go_ahead, 1, ATOMIC_ORDER_RELAXED );
509 Thread_queue_Gate *gate
512 while ( _Atomic_Load_uint( &gate->go_ahead, ATOMIC_ORDER_RELAXED ) == 0 ) {
527#if defined(RTEMS_SMP)
552#if defined(RTEMS_SMP)
553 _SMP_ticket_lock_Initialize( &queue->Lock );
569#
if defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
570 SMP_lock_Stats *lock_stats,
575#if defined(RTEMS_SMP)
576 _SMP_ticket_lock_Acquire(
579 &lock_context->Lock_context.Stats_context
587#if defined(RTEMS_SMP) && defined( RTEMS_PROFILING )
589 _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
590 _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context )
593 _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \
594 _Thread_queue_Queue_do_acquire_critical( queue, lock_context )
608#if defined(RTEMS_SMP)
609 _SMP_ticket_lock_Release(
611 &lock_context->Lock_context.Stats_context
659#if defined(RTEMS_SMP)
670 (void) the_thread_queue;
698#if defined(RTEMS_SMP)
709 (void) the_thread_queue;
722#if defined(RTEMS_DEBUG)
727#if defined(RTEMS_SMP)
728 return the_thread_queue->owner == _SMP_lock_Who_am_I();
741#if defined(RTEMS_SMP)
752 (void) the_thread_queue;
754 _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
781#if defined(RTEMS_SMP)
792 (void) the_thread_queue;
793 _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
809#
if defined(RTEMS_MULTIPROCESSING)
811 Thread_queue_MP_callout mp_callout
826#if defined(RTEMS_MULTIPROCESSING)
827 #define _Thread_queue_Dequeue( \
832 _Thread_queue_Do_dequeue( \
838 #define _Thread_queue_Dequeue( \
843 _Thread_queue_Do_dequeue( \
933#if defined(RTEMS_SMP)
956Status_Control _Thread_queue_Enqueue_sticky(
1114#if defined(RTEMS_SMP)
1135void _Thread_queue_Surrender_sticky(
1180 if ( heads !=
NULL ) {
1181 return ( *operations->
first )( heads );
1318#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING)
1319 #define THREAD_QUEUE_INITIALIZER( _name ) \
1321 .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1322 .owner = SMP_LOCK_NO_OWNER, \
1324 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1330#elif defined(RTEMS_SMP) && defined(RTEMS_DEBUG)
1331 #define THREAD_QUEUE_INITIALIZER( _name ) \
1333 .owner = SMP_LOCK_NO_OWNER, \
1335 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1341#elif defined(RTEMS_SMP) && defined(RTEMS_PROFILING)
1342 #define THREAD_QUEUE_INITIALIZER( _name ) \
1344 .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \
1346 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1352#elif defined(RTEMS_SMP)
1353 #define THREAD_QUEUE_INITIALIZER( _name ) \
1356 .Lock = SMP_TICKET_LOCK_INITIALIZER, \
1363 #define THREAD_QUEUE_INITIALIZER( _name ) \
1382#if defined(RTEMS_SMP)
1383 _SMP_ticket_lock_Destroy( &the_thread_queue->
Queue.Lock );
1384 _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats );
1394#if defined(RTEMS_MULTIPROCESSING)
1395void _Thread_queue_MP_callout_do_nothing(
1406void _Thread_queue_Unblock_proxy(
1422#if defined(RTEMS_SMP)
1423bool _Thread_queue_Path_acquire_critical(
1434void _Thread_queue_Path_release_critical(
1450#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member, msg ) \
1451 RTEMS_STATIC_ASSERT( \
1452 offsetof( object_type, wait_queue_member ) \
1453 == offsetof( Thread_queue_Object, Wait_queue ) \
1454 && RTEMS_HAVE_MEMBER_SAME_TYPE( \
1456 wait_queue_member, \
1457 Thread_queue_Object, \
1463#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \
1464 RTEMS_CONTAINER_OF( \
1466 Thread_queue_Object, \
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Definition: chainimpl.h:505
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:398
RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(ISR_lock_Context *context, ISR_Level level)
Sets the ISR level in the ISR lock context.
Definition: isrlock.h:159
#define _ISR_Get_level()
Return current interrupt level.
Definition: isrlevel.h:128
uint32_t ISR_Level
Definition: isrlevel.h:41
uint32_t Objects_Id
Definition: object.h:80
RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty(Priority_Aggregation *aggregation)
Initializes the priority aggregation empty.
Definition: priorityimpl.h:211
#define _Scheduler_Count
Count of registered schedulers.
Definition: scheduler.h:325
const Scheduler_Control _Scheduler_Table[]
Registered schedulers.
uint32_t States_Control
Definition: states.h:46
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level(Thread_queue_Context *queue_context, ISR_Level level)
Sets the thread queue context ISR level.
Definition: threadqimpl.h:411
RTEMS_INLINE_ROUTINE Thread_Control * _Thread_queue_First_locked(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqimpl.h:1173
RTEMS_INLINE_ROUTINE void _Thread_queue_Release(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Releases the thread queue control and enables interrupts.
Definition: threadqimpl.h:787
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates(Thread_queue_Context *queue_context, size_t update_count)
Sets the priority update count of the thread queue context.
Definition: threadqimpl.h:367
void _Thread_queue_Add_timeout_realtime_timespec(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds a monotonic timespec to the thread and sets the watchdog header to realtime.
Definition: threadqtimeout.c:110
#define _Thread_queue_Context_set_MP_callout(queue_context, mp_callout)
Sets the MP callout in the thread queue context.
Definition: threadqimpl.h:456
Thread_Control *(* Thread_queue_Flush_filter)(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Thread queue flush filter function.
Definition: threadqimpl.h:1223
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:681
void _Thread_queue_Surrender(Thread_queue_Queue *queue, Thread_queue_Heads *heads, Thread_Control *previous_owner, Thread_queue_Context *queue_context, const Thread_queue_Operations *operations)
Surrenders the thread queue previously owned by the thread to the first enqueued thread.
Definition: threadqenqueue.c:660
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(Thread_queue_Context *queue_context, const struct timespec *abstime)
Sets the enqueue callout to add an absolute monotonic timeout in timespec format.
Definition: threadqimpl.h:281
RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty(const Thread_queue_Queue *queue)
Checks if the thread queue queue is empty.
Definition: threadqimpl.h:1152
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_timeout_ticks(Thread_queue_Context *queue_context, Watchdog_Interval ticks)
Sets the timeout ticks in the thread queue context.
Definition: threadqimpl.h:195
RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:704
void _Thread_queue_Enqueue(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Blocks the thread and places it on the thread queue.
Definition: threadqenqueue.c:380
void _Thread_queue_Add_timeout_monotonic_timespec(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds a monotonic timespec to the thread and sets the watchdog header to monotonic.
Definition: threadqtimeout.c:90
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Releases the thread queue queue and enables interrupts.
Definition: threadqimpl.h:625
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_ticks(Thread_queue_Context *queue_context, Watchdog_Interval ticks)
Sets the enqueue callout to add a relative monotonic timeout in ticks.
Definition: threadqimpl.h:262
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update(Thread_queue_Context *queue_context, Thread_Control *the_thread)
Adds a priority update of the thread to the thread queue context.
Definition: threadqimpl.h:383
RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical(Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context)
Releases the thread queue control in a critical section.
Definition: threadqimpl.h:764
void _Thread_queue_Deadlock_fatal(Thread_Control *the_thread)
Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error.
Definition: threadqenqueue.c:375
void _Thread_queue_Enqueue_do_nothing_extra(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Does nothing.
Definition: threadqenqueue.c:360
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_queue_Dispatch_disable(Thread_queue_Context *queue_context)
Disables dispatching in a critical section.
Definition: threadqimpl.h:429
void(* Thread_queue_Enqueue_callout)(Thread_queue_Queue *queue, Thread_Control *the_thread, struct Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Thread queue enqueue callout.
Definition: threadq.h:72
bool _Thread_queue_Extract_locked(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Extracts the thread from the thread queue, restores the default wait operations and restores the defa...
Definition: threadqenqueue.c:565
RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical(Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context)
Checks if the thread queue control is the owner of the lock.
Definition: threadqimpl.h:747
void(* Thread_queue_Deadlock_callout)(Thread_Control *the_thread)
Thread queue deadlock callout.
Definition: threadq.h:86
void _Thread_queue_Extract_with_proxy(Thread_Control *the_thread)
Extracts the_thread from the_thread_queue.
Definition: threadqextractwithproxy.c:30
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize(Thread_queue_Queue *queue, const char *name)
Initializes the thread queue queue with the given name.
Definition: threadqimpl.h:547
const char _Thread_queue_Object_name[]
The special thread queue name to indicated that the thread queue is embedded in an object with identi...
Definition: threadq.c:135
RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy(Thread_queue_Control *the_thread_queue)
Destroys the thread queue.
Definition: threadqimpl.h:1378
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_do_nothing_extra(Thread_queue_Context *queue_context)
Sets the do nothing enqueue callout in the thread queue context.
Definition: threadqimpl.h:245
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_timeout_argument(Thread_queue_Context *queue_context, const void *arg)
Sets the timeout argument in the thread queue context.
Definition: threadqimpl.h:212
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout(Thread_queue_Context *queue_context, Thread_queue_Deadlock_callout deadlock_callout)
Sets the deadlock callout in the thread queue context.
Definition: threadqimpl.h:324
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(Thread_queue_Context *queue_context, const struct timespec *abstime)
Sets the enqueue callout to add an absolute realtime timeout in timespec format.
Definition: threadqimpl.h:301
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_thread_state(Thread_queue_Context *queue_context, States_Control thread_state)
Sets the thread state for the thread to enqueue in the thread queue context.
Definition: threadqimpl.h:178
Thread_Control * _Thread_queue_Flush_status_object_was_deleted(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Status object was deleted thread queue flush filter function.
Definition: threadqflush.c:37
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates(Thread_queue_Context *queue_context)
Clears the priority update count of the thread queue context.
Definition: threadqimpl.h:338
size_t _Thread_queue_Queue_get_name_and_id(const Thread_queue_Queue *queue, char *buffer, size_t buffer_size, Objects_Id *id)
Copies the thread queue name to the specified buffer.
Definition: threadq.c:163
size_t _Thread_queue_Flush_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_queue_Flush_filter filter, Thread_queue_Context *queue_context)
Unblocks all threads enqueued on the thread queue.
Definition: threadqflush.c:63
void _Thread_queue_Deadlock_status(Thread_Control *the_thread)
Sets the thread wait return code to STATUS_DEADLOCK.
Definition: threadqenqueue.c:370
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Acquires the thread queue queue in a critical section.
Definition: threadqimpl.h:567
Thread_Control * _Thread_queue_Do_dequeue(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Dequeues the first thread waiting on the thread queue and returns it.
Definition: threadqenqueue.c:742
Thread_Control * _Thread_queue_First(Thread_queue_Control *the_thread_queue, const Thread_queue_Operations *operations)
Returns the first thread on the thread queue if it exists, otherwise NULL.
Definition: threadqfirst.c:23
void _Thread_queue_Extract(Thread_Control *the_thread)
Extracts thread from thread queue.
Definition: threadqenqueue.c:624
Thread_Control * _Thread_queue_Flush_default_filter(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Default thread queue flush filter function.
Definition: threadqflush.c:26
void _Thread_queue_Object_initialize(Thread_queue_Control *the_thread_queue)
Initializes a thread queue embedded in an object with identifier.
Definition: threadq.c:148
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize(Thread_queue_Context *queue_context)
Initializes a thread queue context.
Definition: threadqimpl.h:152
RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_callout(Thread_queue_Context *queue_context, Thread_queue_Enqueue_callout enqueue_callout)
Sets the enqueue callout in the thread queue context.
Definition: threadqimpl.h:229
void _Thread_queue_Unblock_critical(bool unblock, Thread_queue_Queue *queue, Thread_Control *the_thread, ISR_lock_Context *lock_context)
Unblocks the thread which was on the thread queue before.
Definition: threadqenqueue.c:579
void _Thread_queue_Add_timeout_ticks(Thread_queue_Queue *queue, Thread_Control *the_thread, Per_CPU_Control *cpu_self, Thread_queue_Context *queue_context)
Adds timeout ticks of the queue to the thread.
Definition: threadqtimeout.c:17
void _Thread_queue_Initialize(Thread_queue_Control *the_thread_queue, const char *name)
Initializes the thread queue control to the given name.
Definition: threadq.c:137
RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates(Thread_queue_Context *queue_context)
Returns the priority update count of the thread queue context.
Definition: threadqimpl.h:353
RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize(Thread_queue_Heads *heads)
Initializes the thread queue heads.
Definition: threadqimpl.h:523
RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical(Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context)
Acquires the thread queue control in a critical section.
Definition: threadqimpl.h:665
RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical(Thread_queue_Queue *queue, ISR_lock_Context *lock_context)
Releases the thread queue queue in a critical section.
Definition: threadqimpl.h:603
void _Thread_queue_Extract_critical(Thread_queue_Queue *queue, const Thread_queue_Operations *operations, Thread_Control *the_thread, Thread_queue_Context *queue_context)
Extracts the thread from the thread queue and unblocks it.
Definition: threadqenqueue.c:600
Thread_Control * _Thread_queue_Flush_status_unavailable(Thread_Control *the_thread, Thread_queue_Queue *queue, Thread_queue_Context *queue_context)
Status unavailable thread queue flush filter function.
Definition: threadqflush.c:50
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
Definition: threaddispatch.h:179
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
Priority Handler API Implementation.
Constants and Structures Associated with the Scheduler.
Constants and Structures Related with the Thread Control Block.
SuperCore SMP Support API.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Definition: objectdata.h:39
Per CPU Core Structure.
Definition: percpu.h:347
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Enqueue_callout enqueue_callout
The enqueue callout for _Thread_queue_Enqueue().
Definition: threadq.h:221
struct Thread_queue_Context::@3986 Priority
Block to manage thread priority changes due to a thread queue operation.
Thread_queue_Deadlock_callout deadlock_callout
Invoked in case of a detected deadlock.
Definition: threadq.h:304
const void * arg
The timeout argument, e.g. pointer to struct timespec.
Definition: threadq.h:237
size_t update_count
Count of threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:284
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Watchdog_Interval ticks
The timeout in ticks.
Definition: threadq.h:232
States_Control thread_state
The thread state for _Thread_queue_Enqueue().
Definition: threadq.h:208
Thread_Control * update[2]
Threads to update the priority via _Thread_Priority_update().
Definition: threadq.h:293
union Thread_queue_Context::@3985 Timeout
Interval to wait.
Definition: threadq.h:553
Thread_queue_Queue Queue
The actual thread queue.
Definition: threadq.h:584
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Does nothing.
Definition: threadqimpl.h:1445
Thread queue operations.
Definition: threadq.h:518
Thread_queue_First_operation first
Thread queue first operation.
Definition: threadq.h:546
Priority_Aggregation Queue
The actual thread priority queue.
Definition: threadq.h:338
Definition: threadq.h:402
const char * name
The thread queue name.
Definition: threadq.h:436
Thread_queue_Heads * heads
Lock to protect this thread queue.
Definition: threadq.h:426
Thread_Control * owner
The thread queue owner.
Definition: threadq.h:431
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
Thread queue heads.
Definition: threadq.h:360
Thread_queue_Priority_queue Priority
This is the set of threads for priority discipline waiting.
Definition: threadq.h:378
Chain_Node Free_node
A chain node to add these thread queue heads to the free chain of the thread queue heads dedicated to...
Definition: threadq.h:392
Chain_Control Free_chain
A chain with free thread queue heads providing the spare thread queue heads for a thread once it is d...
Definition: threadq.h:386
Constants and Structures Related with Thread Dispatch.
Constants and Structures Needed to Declare a Thread Queue.