From 1d56a7a8b8a0b48fdeb02f6d4408a8236e8ccf95 Mon Sep 17 00:00:00 2001 From: Glenn Humphrey Date: Tue, 27 Nov 2007 18:38:18 +0000 Subject: 2007-11-27 Glenn Humphrey * posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, rtems/include/rtems/rtems/barrier.h, score/src/corerwlockobtainread.c, score/src/corerwlockobtainwrite.c, score/src/corerwlockrelease.c: Fixed several implementation errors. --- cpukit/score/src/corerwlockrelease.c | 47 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'cpukit/score/src/corerwlockrelease.c') diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index b9d0e2f9e1..4d29cd0f21 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -40,7 +40,6 @@ CORE_RWLock_Status _CORE_RWLock_Release( ISR_Level level; Thread_Control *executing = _Thread_Executing; Thread_Control *next; - uint32_t rwmode; /* * If unlocked, then OK to read. @@ -80,32 +79,30 @@ CORE_RWLock_Status _CORE_RWLock_Release( next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); if ( next ) { - rwmode = next->Wait.option; - if ( rwmode == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; - return CORE_RWLOCK_SUCCESSFUL; - } - - /* - * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING now see if more - * readers can be let go. - */ - - while ( 1 ) { - next = _Thread_queue_First( &the_rwlock->Wait_queue ); - if ( !next ) - return CORE_RWLOCK_SUCCESSFUL; - if ( next->Wait.option != CORE_RWLOCK_THREAD_WAITING_FOR_READ ) - return CORE_RWLOCK_SUCCESSFUL; - - /* it is definitely wanting to read */ - the_rwlock->number_of_readers += 1; - _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); - } + if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { + the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; + return CORE_RWLOCK_SUCCESSFUL; + } - /* XXX need to put read/write lock request indicator in Wait info */ + /* + * Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING + */ + the_rwlock->number_of_readers += 1; + the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING; - } + /* + * Now see if more readers can be let go. + */ + while ( 1 ) { + next = _Thread_queue_First( &the_rwlock->Wait_queue ); + if ( !next || + next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) + return CORE_RWLOCK_SUCCESSFUL; + the_rwlock->number_of_readers += 1; + _Thread_queue_Extract( &the_rwlock->Wait_queue, next ); + } + } + /* indentation is to match _ISR_Disable at top */ return CORE_RWLOCK_SUCCESSFUL; } -- cgit v1.2.3