diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2008-01-29 18:59:00 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2008-01-29 18:59:00 +0000 |
commit | 1ff7e1948e68dd6ff51da63dda0e6f276a281015 (patch) | |
tree | ef15bf635294d4ad420bf3e542f41bc7bf1001d0 /cpukit/score/src/corerwlockrelease.c | |
parent | 2008-01-29 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-1ff7e1948e68dd6ff51da63dda0e6f276a281015.tar.bz2 |
2008-01-29 Jennifer Averett <jennifer.averett@OARcorp.com>
* score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed
switch statements to if statements.
Diffstat (limited to 'cpukit/score/src/corerwlockrelease.c')
-rw-r--r-- | cpukit/score/src/corerwlockrelease.c | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index 4d29cd0f21..98aa973580 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -49,59 +49,57 @@ CORE_RWLock_Status _CORE_RWLock_Release( */ _ISR_Disable( level ); - switch ( the_rwlock->current_state ) { - case CORE_RWLOCK_UNLOCKED: - _ISR_Enable( level ); - executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; - return CORE_RWLOCK_SUCCESSFUL; - - case CORE_RWLOCK_LOCKED_FOR_READING: + if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){ + _ISR_Enable( level ); + executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE; + return CORE_RWLOCK_SUCCESSFUL; + } + if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) { the_rwlock->number_of_readers -= 1; if ( the_rwlock->number_of_readers != 0 ) { /* must be unlocked again */ _ISR_Enable( level ); return CORE_RWLOCK_SUCCESSFUL; } - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - break; - case CORE_RWLOCK_LOCKED_FOR_WRITING: - executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; - break; - } + } + + /* CORE_RWLOCK_LOCKED_FOR_WRITING or READING with readers */ + executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; /* * Implicitly transition to "unlocked" and find another thread interested * in obtaining this rwlock. */ the_rwlock->current_state = CORE_RWLOCK_UNLOCKED; - _ISR_Enable( level ); + _ISR_Enable( level ); - next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); + next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); - if ( next ) { - if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING; - return CORE_RWLOCK_SUCCESSFUL; - } + if ( next ) { + if ( next->Wait.option == 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 - */ - the_rwlock->number_of_readers += 1; - the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_READING; + /* + * 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 ); - } + /* + * 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; |