RTEMS  5.1
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>
28 #include <rtems/score/watchdog.h>
29 
39 #ifdef __cplusplus
40 extern "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 {
71 
76 typedef struct {
81 
85 
88  unsigned int number_of_readers;
90 
99  CORE_RWLock_Control *the_rwlock
100 );
101 
110  CORE_RWLock_Control *the_rwlock
111 )
112 {
113  (void) the_rwlock;
114 }
115 
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 
151  CORE_RWLock_Control *the_rwlock,
152  Thread_queue_Context *queue_context
153 )
154 {
156  &the_rwlock->Queue.Queue,
157  &queue_context->Lock_context.Lock_context
158  );
159 }
160 
176 Status_Control _CORE_RWLock_Seize_for_reading(
177  CORE_RWLock_Control *the_rwlock,
178  bool wait,
179  Thread_queue_Context *queue_context
180 );
181 
197 Status_Control _CORE_RWLock_Seize_for_writing(
198  CORE_RWLock_Control *the_rwlock,
199  bool wait,
200  Thread_queue_Context *queue_context
201 );
202 
213 Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock );
214 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif
222 /* end of include file */
Definition: corerwlockimpl.h:76
Thread queue context for the thread queue methods.
Definition: threadq.h:198
Status_Control _CORE_RWLock_Surrender(CORE_RWLock_Control *the_rwlock)
Releases the RWLock.
Definition: corerwlockrelease.c:76
unsigned int number_of_readers
Definition: corerwlockimpl.h:88
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_States current_state
Definition: corerwlockimpl.h:84
Thread_queue_Syslock_queue Queue
Definition: corerwlockimpl.h:80
Definition: corerwlockimpl.h:69
CORE_RWLock_States
Definition: corerwlockimpl.h:60
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
Definition: thread.h:732
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition: threadqimpl.h:54
uint32_t ISR_Level
Definition: isrlevel.h:41
Definition: corerwlockimpl.h:63
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:203
RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context)
Releases the RWlock.
Definition: corerwlockimpl.h:150
Constants and Structures Associated with the Manipulation of Objects.
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
Constants and Structures Associated with Watchdog Timers.
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:130
Definition: corerwlockimpl.h:66
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
Constants and Structures Related with the Thread Control Block.
RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy(CORE_RWLock_Control *the_rwlock)
Destroys a RWlock.
Definition: corerwlockimpl.h:109
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
void _CORE_RWLock_Initialize(CORE_RWLock_Control *the_rwlock)
Initializes a RWlock.
Definition: corerwlock.c:25
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