summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-21 15:42:45 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-05 14:29:02 +0200
commit89fc9345dea5c675f8d93546fa3c723918d3279a (patch)
tree89c32d64f375e1a9bf9d3725b1256aeb7ca46221 /cpukit/score/src
parentposix: Implement self-contained POSIX barriers (diff)
downloadrtems-89fc9345dea5c675f8d93546fa3c723918d3279a.tar.bz2
posix: Implement self-contained POSIX rwlocks
POSIX rwlocks are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3115.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/corerwlock.c3
-rw-r--r--cpukit/score/src/corerwlockobtainread.c17
-rw-r--r--cpukit/score/src/corerwlockobtainwrite.c7
-rw-r--r--cpukit/score/src/corerwlockrelease.c20
4 files changed, 21 insertions, 26 deletions
diff --git a/cpukit/score/src/corerwlock.c b/cpukit/score/src/corerwlock.c
index 51ae2c70df..9ebb796ac4 100644
--- a/cpukit/score/src/corerwlock.c
+++ b/cpukit/score/src/corerwlock.c
@@ -27,6 +27,5 @@ void _CORE_RWLock_Initialize(
{
the_rwlock->number_of_readers = 0;
the_rwlock->current_state = CORE_RWLOCK_UNLOCKED;
-
- _Thread_queue_Object_initialize( &the_rwlock->Wait_queue );
+ _Thread_queue_Queue_initialize( &the_rwlock->Queue.Queue, NULL );
}
diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c
index 641945635f..d0bd7b09ce 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -26,18 +26,19 @@
Status_Control _CORE_RWLock_Seize_for_reading(
CORE_RWLock_Control *the_rwlock,
- Thread_Control *executing,
bool wait,
Thread_queue_Context *queue_context
)
{
+ Thread_Control *executing;
+
/*
* If unlocked, then OK to read.
* If locked for reading and no waiters, then OK to read.
* If any thread is waiting, then we wait.
*/
- _CORE_RWLock_Acquire_critical( the_rwlock, queue_context );
+ executing = _CORE_RWLock_Acquire( the_rwlock, queue_context );
switch ( the_rwlock->current_state ) {
case CORE_RWLOCK_UNLOCKED:
@@ -46,19 +47,13 @@ Status_Control _CORE_RWLock_Seize_for_reading(
_CORE_RWLock_Release( the_rwlock, queue_context );
return STATUS_SUCCESSFUL;
- case CORE_RWLOCK_LOCKED_FOR_READING: {
- Thread_Control *waiter;
- waiter = _Thread_queue_First_locked(
- &the_rwlock->Wait_queue,
- CORE_RWLOCK_TQ_OPERATIONS
- );
- if ( !waiter ) {
+ case CORE_RWLOCK_LOCKED_FOR_READING:
+ if ( _Thread_queue_Is_empty( &the_rwlock->Queue.Queue ) ) {
the_rwlock->number_of_readers += 1;
_CORE_RWLock_Release( the_rwlock, queue_context );
return STATUS_SUCCESSFUL;
}
break;
- }
case CORE_RWLOCK_LOCKED_FOR_WRITING:
break;
}
@@ -84,7 +79,7 @@ Status_Control _CORE_RWLock_Seize_for_reading(
);
_Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context );
_Thread_queue_Enqueue(
- &the_rwlock->Wait_queue.Queue,
+ &the_rwlock->Queue.Queue,
CORE_RWLOCK_TQ_OPERATIONS,
executing,
queue_context
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c
index 7f636daa99..6859163f1f 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -26,11 +26,12 @@
Status_Control _CORE_RWLock_Seize_for_writing(
CORE_RWLock_Control *the_rwlock,
- Thread_Control *executing,
bool wait,
Thread_queue_Context *queue_context
)
{
+ Thread_Control *executing;
+
/*
* If unlocked, then OK to read.
* Otherwise, we have to block.
@@ -38,7 +39,7 @@ Status_Control _CORE_RWLock_Seize_for_writing(
* If any thread is waiting, then we wait.
*/
- _CORE_RWLock_Acquire_critical( the_rwlock, queue_context );
+ executing = _CORE_RWLock_Acquire( the_rwlock, queue_context );
switch ( the_rwlock->current_state ) {
case CORE_RWLOCK_UNLOCKED:
@@ -72,7 +73,7 @@ Status_Control _CORE_RWLock_Seize_for_writing(
);
_Thread_queue_Context_set_do_nothing_enqueue_callout( queue_context );
_Thread_queue_Enqueue(
- &the_rwlock->Wait_queue.Queue,
+ &the_rwlock->Queue.Queue,
CORE_RWLOCK_TQ_OPERATIONS,
executing,
queue_context
diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c
index 71aa12a190..772d16dc25 100644
--- a/cpukit/score/src/corerwlockrelease.c
+++ b/cpukit/score/src/corerwlockrelease.c
@@ -45,7 +45,7 @@ static Thread_Control *_CORE_RWLock_Flush_filter(
the_rwlock = RTEMS_CONTAINER_OF(
queue,
CORE_RWLock_Control,
- Wait_queue.Queue
+ Queue.Queue
);
switch ( the_rwlock->current_state ) {
@@ -73,11 +73,10 @@ static Thread_Control *_CORE_RWLock_Flush_filter(
return the_thread;
}
-Status_Control _CORE_RWLock_Surrender(
- CORE_RWLock_Control *the_rwlock,
- Thread_queue_Context *queue_context
-)
+Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock )
{
+ Thread_queue_Context queue_context;
+
/*
* If unlocked, then OK to read.
* Otherwise, we have to block.
@@ -85,11 +84,12 @@ Status_Control _CORE_RWLock_Surrender(
* If any thread is waiting, then we wait.
*/
- _CORE_RWLock_Acquire_critical( the_rwlock, queue_context );
+ _Thread_queue_Context_initialize( &queue_context );
+ _CORE_RWLock_Acquire( the_rwlock, &queue_context );
if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){
/* This is an error at the caller site */
- _CORE_RWLock_Release( the_rwlock, queue_context );
+ _CORE_RWLock_Release( the_rwlock, &queue_context );
return STATUS_SUCCESSFUL;
}
@@ -98,7 +98,7 @@ Status_Control _CORE_RWLock_Surrender(
if ( the_rwlock->number_of_readers != 0 ) {
/* must be unlocked again */
- _CORE_RWLock_Release( the_rwlock, queue_context );
+ _CORE_RWLock_Release( the_rwlock, &queue_context );
return STATUS_SUCCESSFUL;
}
}
@@ -116,10 +116,10 @@ Status_Control _CORE_RWLock_Surrender(
the_rwlock->current_state = CORE_RWLOCK_UNLOCKED;
_Thread_queue_Flush_critical(
- &the_rwlock->Wait_queue.Queue,
+ &the_rwlock->Queue.Queue,
CORE_RWLOCK_TQ_OPERATIONS,
_CORE_RWLock_Flush_filter,
- queue_context
+ &queue_context
);
return STATUS_SUCCESSFUL;
}