00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RTEMS_SCORE_CORERWLOCK_H
00020 #define _RTEMS_SCORE_CORERWLOCK_H
00021
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034 #include <rtems/score/thread.h>
00035 #include <rtems/score/threadq.h>
00036 #include <rtems/score/priority.h>
00037 #include <rtems/score/watchdog.h>
00038
00043 typedef void ( *CORE_RWLock_API_mp_support_callout )(
00044 Thread_Control *,
00045 Objects_Id
00046 );
00047
00051 typedef enum {
00054 CORE_RWLOCK_UNLOCKED,
00057 CORE_RWLOCK_LOCKED_FOR_READING,
00060 CORE_RWLOCK_LOCKED_FOR_WRITING
00061 } CORE_RWLock_States;
00062
00066 typedef enum {
00068 CORE_RWLOCK_SUCCESSFUL,
00070 CORE_RWLOCK_WAS_DELETED,
00072 CORE_RWLOCK_UNAVAILABLE,
00077 CORE_RWLOCK_TIMEOUT
00078 } CORE_RWLock_Status;
00079
00082 #define CORE_RWLOCK_STATUS_LAST CORE_RWLOCK_TIMEOUT
00083
00088 #define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0
00089
00094 #define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1
00095
00100 typedef struct {
00103 int XXX;
00104 } CORE_RWLock_Attributes;
00105
00110 typedef struct {
00114 Thread_queue_Control Wait_queue;
00118 CORE_RWLock_Attributes Attributes;
00121 CORE_RWLock_States current_state;
00124 uint32_t number_of_readers;
00125 } CORE_RWLock_Control;
00126
00133 void _CORE_RWLock_Initialize(
00134 CORE_RWLock_Control *the_rwlock,
00135 CORE_RWLock_Attributes *the_rwlock_attributes
00136 );
00137
00151 void _CORE_RWLock_Obtain_for_reading(
00152 CORE_RWLock_Control *the_rwlock,
00153 Objects_Id id,
00154 boolean wait,
00155 Watchdog_Interval timeout,
00156 CORE_RWLock_API_mp_support_callout api_rwlock_mp_support
00157 );
00158
00172 void _CORE_RWLock_Obtain_for_writing(
00173 CORE_RWLock_Control *the_rwlock,
00174 Objects_Id id,
00175 boolean wait,
00176 Watchdog_Interval timeout,
00177 CORE_RWLock_API_mp_support_callout api_rwlock_mp_support
00178 );
00179
00188 CORE_RWLock_Status _CORE_RWLock_Release(
00189 CORE_RWLock_Control *the_rwlock
00190 );
00191
00201 #define _CORE_RWLock_Flush( _the_rwlock, _remote_extract_callout, _status) \
00202 _Thread_queue_Flush( \
00203 &((_the_rwlock)->Wait_queue), \
00204 (_remote_extract_callout), \
00205 (_status) \
00206 )
00207
00218 void _CORE_RWLock_Timeout(
00219 Objects_Id id,
00220 void *ignored
00221 );
00222
00223
00224 #ifndef __RTEMS_APPLICATION__
00225 #include <rtems/score/corerwlock.inl>
00226 #endif
00227
00228 #ifdef __cplusplus
00229 }
00230 #endif
00231
00234 #endif
00235