mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
2008-01-29 Jennifer Averett <jennifer.averett@OARcorp.com>
* score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed switch statements to if statements.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2008-01-29 Jennifer Averett <jennifer.averett@OARcorp.com>
|
||||||
|
|
||||||
|
* score/src/corerwlockrelease.c, score/src/coresemseize.c: Changed
|
||||||
|
switch statements to if statements.
|
||||||
|
|
||||||
2008-01-29 Joel Sherrill <joel.sherrill@OARcorp.com>
|
2008-01-29 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
|
* libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h,
|
||||||
|
|||||||
@@ -49,59 +49,57 @@ CORE_RWLock_Status _CORE_RWLock_Release(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_ISR_Disable( level );
|
_ISR_Disable( level );
|
||||||
switch ( the_rwlock->current_state ) {
|
if ( the_rwlock->current_state == CORE_RWLOCK_UNLOCKED){
|
||||||
case CORE_RWLOCK_UNLOCKED:
|
_ISR_Enable( level );
|
||||||
_ISR_Enable( level );
|
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
||||||
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
return CORE_RWLOCK_SUCCESSFUL;
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
}
|
||||||
|
if ( the_rwlock->current_state == CORE_RWLOCK_LOCKED_FOR_READING ) {
|
||||||
case CORE_RWLOCK_LOCKED_FOR_READING:
|
|
||||||
the_rwlock->number_of_readers -= 1;
|
the_rwlock->number_of_readers -= 1;
|
||||||
if ( the_rwlock->number_of_readers != 0 ) {
|
if ( the_rwlock->number_of_readers != 0 ) {
|
||||||
/* must be unlocked again */
|
/* must be unlocked again */
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
return CORE_RWLOCK_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
|
}
|
||||||
break;
|
|
||||||
case CORE_RWLOCK_LOCKED_FOR_WRITING:
|
/* CORE_RWLOCK_LOCKED_FOR_WRITING or READING with readers */
|
||||||
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
|
executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implicitly transition to "unlocked" and find another thread interested
|
* Implicitly transition to "unlocked" and find another thread interested
|
||||||
* in obtaining this rwlock.
|
* in obtaining this rwlock.
|
||||||
*/
|
*/
|
||||||
the_rwlock->current_state = CORE_RWLOCK_UNLOCKED;
|
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 ) {
|
||||||
if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
|
if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
|
||||||
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
|
the_rwlock->current_state = CORE_RWLOCK_LOCKED_FOR_WRITING;
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
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;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 */
|
/* indentation is to match _ISR_Disable at top */
|
||||||
|
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
return CORE_RWLOCK_SUCCESSFUL;
|
||||||
|
|||||||
@@ -69,23 +69,23 @@ void _CORE_semaphore_Seize(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( wait ) {
|
if ( wait == CORE_SEMAPHORE_NO_WAIT ) {
|
||||||
case CORE_SEMAPHORE_NO_WAIT:
|
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
|
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
|
||||||
return;
|
return;
|
||||||
case CORE_SEMAPHORE_BAD_TIMEOUT:
|
}
|
||||||
|
if (wait == CORE_SEMAPHORE_BAD_TIMEOUT ) {
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
|
executing->Wait.return_code = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
|
||||||
return;
|
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 );
|
_Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
|
||||||
executing->Wait.queue = &the_semaphore->Wait_queue;
|
executing->Wait.queue = &the_semaphore->Wait_queue;
|
||||||
executing->Wait.id = id;
|
executing->Wait.id = id;
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
|
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user