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 | |
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')
-rw-r--r-- | cpukit/score/src/corerwlockrelease.c | 70 | ||||
-rw-r--r-- | cpukit/score/src/coresemseize.c | 12 |
2 files changed, 40 insertions, 42 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; diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c index 693a19a713..71b8a26c8b 100644 --- a/cpukit/score/src/coresemseize.c +++ b/cpukit/score/src/coresemseize.c @@ -69,23 +69,23 @@ void _CORE_semaphore_Seize( return; } - switch ( wait ) { - case CORE_SEMAPHORE_NO_WAIT: + if ( wait == CORE_SEMAPHORE_NO_WAIT ) { _ISR_Enable( level ); executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; return; - case CORE_SEMAPHORE_BAD_TIMEOUT: + } + if (wait == CORE_SEMAPHORE_BAD_TIMEOUT ) { _ISR_Enable( level ); executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; return; - case CORE_SEMAPHORE_BLOCK_FOREVER: - case CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT: + } + if (( wait == CORE_SEMAPHORE_BLOCK_FOREVER) || + ( wait == CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT ) ) { _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue ); executing->Wait.queue = &the_semaphore->Wait_queue; executing->Wait.id = id; _ISR_Enable( level ); _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); - break; } } |