RTEMS 6.1-rc7
Loading...
Searching...
No Matches
corerwlockimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * COPYRIGHT (c) 1989-2008.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H
39#define _RTEMS_SCORE_CORERWLOCKIMPL_H
40
41#include <rtems/score/percpu.h>
42#include <rtems/score/status.h>
43#include <rtems/score/thread.h>
46
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
62
67#define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0
68
73#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
74
78typedef enum {
89
94typedef struct {
99
103
106 unsigned int number_of_readers;
108
117 CORE_RWLock_Control *the_rwlock
118);
119
127static inline void _CORE_RWLock_Destroy(
128 CORE_RWLock_Control *the_rwlock
129)
130{
131 (void) the_rwlock;
132}
133
142static inline Thread_Control *_CORE_RWLock_Acquire(
143 CORE_RWLock_Control *the_rwlock,
144 Thread_queue_Context *queue_context
145)
146{
147 ISR_Level level;
148 Thread_Control *executing;
149
150 _Thread_queue_Context_ISR_disable( queue_context, level );
151 _Thread_queue_Context_set_ISR_level( queue_context, level );
152 executing = _Thread_Executing;
153 _Thread_queue_Queue_acquire_critical(
154 &the_rwlock->Queue.Queue,
155 &executing->Potpourri_stats,
156 &queue_context->Lock_context.Lock_context
157 );
158
159 return executing;
160}
161
168static inline void _CORE_RWLock_Release(
169 CORE_RWLock_Control *the_rwlock,
170 Thread_queue_Context *queue_context
171)
172{
173 _Thread_queue_Queue_release(
174 &the_rwlock->Queue.Queue,
175 &queue_context->Lock_context.Lock_context
176 );
177}
178
195 CORE_RWLock_Control *the_rwlock,
196 bool wait,
197 Thread_queue_Context *queue_context
198);
199
216 CORE_RWLock_Control *the_rwlock,
217 bool wait,
218 Thread_queue_Context *queue_context
219);
220
232
235#ifdef __cplusplus
236}
237#endif
238
239#endif
240/* end of include file */
This header file provides interfaces of the Watchdog Handler which are used by the implementation and...
uint32_t ISR_Level
Definition: isrlevel.h:60
Status_Control _CORE_RWLock_Seize_for_reading(CORE_RWLock_Control *the_rwlock, bool wait, Thread_queue_Context *queue_context)
Obtains RWLock for reading.
Definition: corerwlockobtainread.c:48
Status_Control _CORE_RWLock_Surrender(CORE_RWLock_Control *the_rwlock)
Releases the RWLock.
Definition: corerwlockrelease.c:96
CORE_RWLock_States
Definition: corerwlockimpl.h:78
Status_Control _CORE_RWLock_Seize_for_writing(CORE_RWLock_Control *the_rwlock, bool wait, Thread_queue_Context *queue_context)
Obtains RWLock for writing.
Definition: corerwlockobtainwrite.c:48
void _CORE_RWLock_Initialize(CORE_RWLock_Control *the_rwlock)
Initializes a RWlock.
Definition: corerwlock.c:45
@ CORE_RWLOCK_UNLOCKED
Definition: corerwlockimpl.h:81
@ CORE_RWLOCK_LOCKED_FOR_READING
Definition: corerwlockimpl.h:84
@ CORE_RWLOCK_LOCKED_FOR_WRITING
Definition: corerwlockimpl.h:87
Status_Control
Status codes.
Definition: status.h:111
This header file provides the interfaces of the Per-CPU Information.
This header file provides the interfaces of the Operation Status Support.
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
Definition: corerwlockimpl.h:94
Thread_queue_Syslock_queue Queue
Definition: corerwlockimpl.h:98
unsigned int number_of_readers
Definition: corerwlockimpl.h:106
CORE_RWLock_States current_state
Definition: corerwlockimpl.h:102
Thread queue context for the thread queue methods.
Definition: threadq.h:216
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:221
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:148
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:71
Definition: thread.h:837
This header file provides interfaces of the Thread Queue Handler which are only used by the implement...