RTEMS: cpukit/include/rtems/score/corerwlockimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
corerwlockimpl.h
Go to the documentation of this file.
1
12/*
13 * COPYRIGHT (c) 1989-2008.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H
22#define _RTEMS_SCORE_CORERWLOCKIMPL_H
23
24#include <rtems/score/percpu.h>
25#include <rtems/score/status.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/threadqimpl.h>
28#include <rtems/score/watchdog.h>
29
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
44
49#define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0
50
55#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
56
60 typedef enum {
63 CORE_RWLOCK_UNLOCKED,
66 CORE_RWLOCK_LOCKED_FOR_READING,
69 CORE_RWLOCK_LOCKED_FOR_WRITING
70} CORE_RWLock_States;
71
76 typedef struct {
80 Thread_queue_Syslock_queue Queue;
81
84 CORE_RWLock_States current_state;
85
88 unsigned int number_of_readers;
89} CORE_RWLock_Control;
90
98void _CORE_RWLock_Initialize(
99 CORE_RWLock_Control *the_rwlock
100);
101
109 RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy(
110 CORE_RWLock_Control *the_rwlock
111)
112{
113 (void) the_rwlock;
114}
115
124 RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire(
125 CORE_RWLock_Control *the_rwlock,
126 Thread_queue_Context *queue_context
127)
128{
129 ISR_Level level;
130 Thread_Control *executing;
131
132 _Thread_queue_Context_ISR_disable( queue_context, level );
133 _Thread_queue_Context_set_ISR_level( queue_context, level );
134 executing = _Thread_Executing;
135 _Thread_queue_Queue_acquire_critical(
136 &the_rwlock->Queue.Queue,
137 &executing->Potpourri_stats,
138 &queue_context->Lock_context.Lock_context
139 );
140
141 return executing;
142}
143
150 RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
151 CORE_RWLock_Control *the_rwlock,
152 Thread_queue_Context *queue_context
153)
154{
155 _Thread_queue_Queue_release(
156 &the_rwlock->Queue.Queue,
157 &queue_context->Lock_context.Lock_context
158 );
159}
160
176Status_Control _CORE_RWLock_Seize_for_reading(
177 CORE_RWLock_Control *the_rwlock,
178 bool wait,
179 Thread_queue_Context *queue_context
180);
181
197Status_Control _CORE_RWLock_Seize_for_writing(
198 CORE_RWLock_Control *the_rwlock,
199 bool wait,
200 Thread_queue_Context *queue_context
201);
202
213Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock );
214
217#ifdef __cplusplus
218}
219#endif
220
221#endif
222/* end of include file */
watchdog.h
Constants and Structures Associated with Watchdog Timers.
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
ISR_Level
uint32_t ISR_Level
Definition: isrlevel.h:41
_CORE_RWLock_Release
RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context)
Releases the RWlock.
Definition: corerwlockimpl.h:150
_CORE_RWLock_Seize_for_reading
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:28
_CORE_RWLock_Surrender
Status_Control _CORE_RWLock_Surrender(CORE_RWLock_Control *the_rwlock)
Releases the RWLock.
Definition: corerwlockrelease.c:76
CORE_RWLock_States
CORE_RWLock_States
Definition: corerwlockimpl.h:60
_CORE_RWLock_Seize_for_writing
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:28
_CORE_RWLock_Initialize
void _CORE_RWLock_Initialize(CORE_RWLock_Control *the_rwlock)
Initializes a RWlock.
Definition: corerwlock.c:25
_CORE_RWLock_Destroy
RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy(CORE_RWLock_Control *the_rwlock)
Destroys a RWlock.
Definition: corerwlockimpl.h:109
_CORE_RWLock_Acquire
RTEMS_INLINE_ROUTINE Thread_Control * _CORE_RWLock_Acquire(CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context)
Acquires the RWlock.
Definition: corerwlockimpl.h:124
CORE_RWLOCK_UNLOCKED
@ CORE_RWLOCK_UNLOCKED
Definition: corerwlockimpl.h:63
CORE_RWLOCK_LOCKED_FOR_READING
@ CORE_RWLOCK_LOCKED_FOR_READING
Definition: corerwlockimpl.h:66
CORE_RWLOCK_LOCKED_FOR_WRITING
@ CORE_RWLOCK_LOCKED_FOR_WRITING
Definition: corerwlockimpl.h:69
_Thread_queue_Context_set_ISR_level
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
_Thread_queue_Queue_release
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
percpu.h
thread.h
Constants and Structures Related with the Thread Control Block.
CORE_RWLock_Control
Definition: corerwlockimpl.h:76
CORE_RWLock_Control::Queue
Thread_queue_Syslock_queue Queue
Definition: corerwlockimpl.h:80
CORE_RWLock_Control::number_of_readers
unsigned int number_of_readers
Definition: corerwlockimpl.h:88
CORE_RWLock_Control::current_state
CORE_RWLock_States current_state
Definition: corerwlockimpl.h:84
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Thread_queue_Context::Lock_context
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
Thread_queue_Lock_context::Lock_context
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Thread_queue_Syslock_queue
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
_Thread_Control
Definition: thread.h:732
threadqimpl.h
Constants and Structures Associated with the Manipulation of Objects.