source: rtems/cpukit/score/src/threadq.c

Last change on this file was 80b3c938, checked in by Sebastian Huber <sebastian.huber@…>, on May 17, 2021 at 2:55:15 PM

score: Move _Thread_queue_Queue_get_name_and_id()

Move this diagnostic function to a separate file since it does not
provide a core function of the system.

Change license to BSD-2-Clause according to file history and
re-licensing agreement.

Update #3053.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreThreadQueue
5 *
6 * @brief This source file contains static assertions related to the Thread
7 *   Queue Handler, the definition of ::_Thread_queue_Object_name, and the
8 *   implementation of _Thread_queue_Acquire(),
9 *   _Thread_queue_Do_acquire_critical(), _Thread_queue_Initialize(),
10 *   _Thread_queue_MP_callout_do_nothing(), _Thread_queue_Object_initialize(),
11 *   _Thread_queue_Queue_get_name_and_id(), _Thread_queue_Release(), and
12 *   _Thread_queue_Release_critical().
13 */
14
15/*
16 *  COPYRIGHT (c) 1989-2014.
17 *  On-Line Applications Research Corporation (OAR).
18 *
19 *  The license and distribution terms for this file may be
20 *  found in the file LICENSE in this distribution or at
21 *  http://www.rtems.org/license/LICENSE.
22 */
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include <rtems/score/threadqimpl.h>
29
30RTEMS_STATIC_ASSERT(
31#if defined(RTEMS_SMP)
32  offsetof( Thread_queue_Syslock_queue, Queue.Lock.next_ticket )
33#else
34  offsetof( Thread_queue_Syslock_queue, reserved[ 0 ] )
35#endif
36    == offsetof( struct _Thread_queue_Queue, _Lock._next_ticket ),
37  THREAD_QUEUE_SYSLOCK_QUEUE_NEXT_TICKET
38);
39
40RTEMS_STATIC_ASSERT(
41#if defined(RTEMS_SMP)
42  offsetof( Thread_queue_Syslock_queue, Queue.Lock.now_serving )
43#else
44  offsetof( Thread_queue_Syslock_queue, reserved[ 1 ] )
45#endif
46    == offsetof( struct _Thread_queue_Queue, _Lock._now_serving ),
47  THREAD_QUEUE_SYSLOCK_QUEUE_NOW_SERVING
48);
49
50RTEMS_STATIC_ASSERT(
51  offsetof( Thread_queue_Syslock_queue, Queue.heads )
52    == offsetof( struct _Thread_queue_Queue, _heads ),
53  THREAD_QUEUE_SYSLOCK_QUEUE_HEADS
54);
55
56RTEMS_STATIC_ASSERT(
57  offsetof( Thread_queue_Syslock_queue, Queue.owner )
58    == offsetof( struct _Thread_queue_Queue, _owner ),
59  THREAD_QUEUE_SYSLOCK_QUEUE_OWNER
60);
61
62RTEMS_STATIC_ASSERT(
63  offsetof( Thread_queue_Syslock_queue, Queue.name )
64    == offsetof( struct _Thread_queue_Queue, _name ),
65  THREAD_QUEUE_SYSLOCK_QUEUE_NAME
66);
67
68RTEMS_STATIC_ASSERT(
69  sizeof( Thread_queue_Syslock_queue )
70    == sizeof( struct _Thread_queue_Queue ),
71  THREAD_QUEUE_SYSLOCK_QUEUE_SIZE
72);
73
74#if defined(RTEMS_SMP)
75void _Thread_queue_Do_acquire_critical(
76  Thread_queue_Control *the_thread_queue,
77  ISR_lock_Context     *lock_context
78)
79{
80  _Thread_queue_Queue_acquire_critical(
81    &the_thread_queue->Queue,
82    &the_thread_queue->Lock_stats,
83    lock_context
84  );
85#if defined(RTEMS_DEBUG)
86  the_thread_queue->owner = _SMP_lock_Who_am_I();
87#endif
88}
89
90void _Thread_queue_Acquire(
91  Thread_queue_Control *the_thread_queue,
92  Thread_queue_Context *queue_context
93)
94{
95  _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
96  _Thread_queue_Queue_acquire_critical(
97    &the_thread_queue->Queue,
98    &the_thread_queue->Lock_stats,
99    &queue_context->Lock_context.Lock_context
100  );
101#if defined(RTEMS_DEBUG)
102  the_thread_queue->owner = _SMP_lock_Who_am_I();
103#endif
104}
105
106void _Thread_queue_Do_release_critical(
107  Thread_queue_Control *the_thread_queue,
108  ISR_lock_Context     *lock_context
109)
110{
111#if defined(RTEMS_DEBUG)
112  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
113  the_thread_queue->owner = SMP_LOCK_NO_OWNER;
114#endif
115  _Thread_queue_Queue_release_critical(
116    &the_thread_queue->Queue,
117    lock_context
118  );
119}
120
121void _Thread_queue_Release(
122  Thread_queue_Control *the_thread_queue,
123  Thread_queue_Context *queue_context
124)
125{
126#if defined(RTEMS_DEBUG)
127  _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) );
128  the_thread_queue->owner = SMP_LOCK_NO_OWNER;
129#endif
130  _Thread_queue_Queue_release_critical(
131    &the_thread_queue->Queue,
132    &queue_context->Lock_context.Lock_context
133  );
134  _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
135}
136#endif
137
138const char _Thread_queue_Object_name[] = { '\0' };
139
140void _Thread_queue_Initialize(
141  Thread_queue_Control *the_thread_queue,
142  const char           *name
143)
144{
145  _Thread_queue_Queue_initialize( &the_thread_queue->Queue, name );
146#if defined(RTEMS_SMP)
147  _SMP_lock_Stats_initialize( &the_thread_queue->Lock_stats, "Thread Queue" );
148#endif
149}
150
151void _Thread_queue_Object_initialize( Thread_queue_Control *the_thread_queue )
152{
153  _Thread_queue_Initialize( the_thread_queue, _Thread_queue_Object_name );
154}
155
156#if defined(RTEMS_MULTIPROCESSING)
157void _Thread_queue_MP_callout_do_nothing(
158  Thread_Control *the_proxy,
159  Objects_Id      mp_id
160)
161{
162  /* Do nothing */
163}
164#endif
Note: See TracBrowser for help on using the repository browser.