RTEMS  5.0.0
corerwlockimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2008.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H
20 #define _RTEMS_SCORE_CORERWLOCKIMPL_H
21 
22 #include <rtems/score/percpu.h>
23 #include <rtems/score/status.h>
24 #include <rtems/score/thread.h>
26 #include <rtems/score/watchdog.h>
27 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
42 
47 #define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0
48 
53 #define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
54 
58 typedef enum {
69 
74 typedef struct {
79 
82  CORE_RWLock_States current_state;
83 
86  unsigned int number_of_readers;
88 
97  CORE_RWLock_Control *the_rwlock
98 );
99 
100 RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy(
101  CORE_RWLock_Control *the_rwlock
102 )
103 {
104  (void) the_rwlock;
105 }
106 
107 RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire(
108  CORE_RWLock_Control *the_rwlock,
109  Thread_queue_Context *queue_context
110 )
111 {
112  ISR_Level level;
113  Thread_Control *executing;
114 
115  _Thread_queue_Context_ISR_disable( queue_context, level );
116  _Thread_queue_Context_set_ISR_level( queue_context, level );
117  executing = _Thread_Executing;
118  _Thread_queue_Queue_acquire_critical(
119  &the_rwlock->Queue.Queue,
120  &executing->Potpourri_stats,
121  &queue_context->Lock_context.Lock_context
122  );
123 
124  return executing;
125 }
126 
127 RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release(
128  CORE_RWLock_Control *the_rwlock,
129  Thread_queue_Context *queue_context
130 )
131 {
132  _Thread_queue_Queue_release(
133  &the_rwlock->Queue.Queue,
134  &queue_context->Lock_context.Lock_context
135  );
136 }
137 
147 Status_Control _CORE_RWLock_Seize_for_reading(
148  CORE_RWLock_Control *the_rwlock,
149  bool wait,
150  Thread_queue_Context *queue_context
151 );
152 
161 Status_Control _CORE_RWLock_Seize_for_writing(
162  CORE_RWLock_Control *the_rwlock,
163  bool wait,
164  Thread_queue_Context *queue_context
165 );
166 
177 Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock );
178 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif
186 /* end of include file */
Definition: corerwlockimpl.h:74
Status_Control _CORE_RWLock_Seize_for_reading(CORE_RWLock_Control *the_rwlock, bool wait, Thread_queue_Context *queue_context)
Obtain RWLock for reading.
Definition: corerwlockobtainread.c:27
Thread queue context for the thread queue methods.
Definition: threadq.h:193
unsigned int number_of_readers
Definition: corerwlockimpl.h:86
Definition: corerwlockimpl.h:61
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
CORE_RWLock_States current_state
Definition: corerwlockimpl.h:82
Thread_queue_Syslock_queue Queue
Definition: corerwlockimpl.h:78
Status_Control _CORE_RWLock_Surrender(CORE_RWLock_Control *the_rwlock)
Release the RWLock.
Definition: corerwlockrelease.c:76
uint32_t ISR_Level
Definition: isrlevel.h:38
Definition: thread.h:728
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock...
Definition: threadqimpl.h:51
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:198
Constants and Structures Associated with Watchdog Timers.
Status_Control _CORE_RWLock_Seize_for_writing(CORE_RWLock_Control *the_rwlock, bool wait, Thread_queue_Context *queue_context)
Obtain RWLock for writing.
Definition: corerwlockobtainwrite.c:27
CORE_RWLock_States
Definition: corerwlockimpl.h:58
void _CORE_RWLock_Initialize(CORE_RWLock_Control *the_rwlock)
Initialize a RWlock.
Definition: corerwlock.c:24
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition: threadq.h:125
Definition: corerwlockimpl.h:64
Definition: corerwlockimpl.h:67
Constants and Structures Related with the Thread Control Block.