mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-08 08:33:19 +00:00
2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* 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.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com>
|
2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com>
|
||||||
|
|
||||||
* rtems/src/regioncreate.c, rtems/src/regiondelete.c,
|
* rtems/src/regioncreate.c, rtems/src/regiondelete.c,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ int pthread_rwlock_timedrdlock(
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
||||||
if ( !status )
|
if ( status )
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ int pthread_rwlock_timedwrlock(
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
|
||||||
if ( !status )
|
if ( status )
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ rtems_status_code rtems_barrier_delete(
|
|||||||
* clock ticks.
|
* clock ticks.
|
||||||
*
|
*
|
||||||
* @param[in] id indicates the barrier to wait at.
|
* @param[in] id indicates the barrier to wait at.
|
||||||
* @param[in] option_set indicates if the caller is willing to wait.
|
|
||||||
* @param[in] timeout is the maximum length of time in ticks the calling
|
* @param[in] timeout is the maximum length of time in ticks the calling
|
||||||
* thread is willing to block.
|
* thread is willing to block.
|
||||||
*
|
*
|
||||||
@@ -161,17 +160,17 @@ rtems_status_code rtems_barrier_wait(
|
|||||||
*
|
*
|
||||||
* This routine implements the rtems_barrier_release directive. It
|
* This routine implements the rtems_barrier_release directive. It
|
||||||
* unblocks all of the threads waiting on the barrier associated with
|
* unblocks all of the threads waiting on the barrier associated with
|
||||||
* @a id. The number of threads unblocked is returns in @a unblocked.
|
* @a id. The number of threads unblocked is returned in @a released.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param[in] id indicates the barrier to wait at.
|
* @param[in] id indicates the barrier to wait at.
|
||||||
* @param[out] unblocked will contain the number of threads unblocked.
|
* @param[out] released will contain the number of threads unblocked.
|
||||||
*
|
*
|
||||||
* @return a status code indicating success or the reason for failure.
|
* @return a status code indicating success or the reason for failure.
|
||||||
*/
|
*/
|
||||||
rtems_status_code rtems_barrier_release(
|
rtems_status_code rtems_barrier_release(
|
||||||
rtems_id id,
|
rtems_id id,
|
||||||
uint32_t *unblocked
|
uint32_t *released
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ void _CORE_RWLock_Obtain_for_reading(
|
|||||||
if ( !wait ) {
|
if ( !wait ) {
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ void _CORE_RWLock_Obtain_for_writing(
|
|||||||
if ( !wait ) {
|
if ( !wait ) {
|
||||||
_ISR_Enable( level );
|
_ISR_Enable( level );
|
||||||
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
executing->Wait.return_code = CORE_RWLOCK_UNAVAILABLE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ CORE_RWLock_Status _CORE_RWLock_Release(
|
|||||||
ISR_Level level;
|
ISR_Level level;
|
||||||
Thread_Control *executing = _Thread_Executing;
|
Thread_Control *executing = _Thread_Executing;
|
||||||
Thread_Control *next;
|
Thread_Control *next;
|
||||||
uint32_t rwmode;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If unlocked, then OK to read.
|
* If unlocked, then OK to read.
|
||||||
@@ -80,32 +79,30 @@ CORE_RWLock_Status _CORE_RWLock_Release(
|
|||||||
next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
|
next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue );
|
||||||
|
|
||||||
if ( next ) {
|
if ( next ) {
|
||||||
rwmode = next->Wait.option;
|
if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) {
|
||||||
if ( rwmode == 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 now see if more
|
* Must be CORE_RWLOCK_THREAD_WAITING_FOR_READING
|
||||||
* readers can be let go.
|
|
||||||
*/
|
*/
|
||||||
|
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 ) {
|
while ( 1 ) {
|
||||||
next = _Thread_queue_First( &the_rwlock->Wait_queue );
|
next = _Thread_queue_First( &the_rwlock->Wait_queue );
|
||||||
if ( !next )
|
if ( !next ||
|
||||||
|
next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE )
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
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;
|
the_rwlock->number_of_readers += 1;
|
||||||
_Thread_queue_Extract( &the_rwlock->Wait_queue, next );
|
_Thread_queue_Extract( &the_rwlock->Wait_queue, next );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX need to put read/write lock request indicator in Wait info */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* indentation is to match _ISR_Disable at top */
|
||||||
|
|
||||||
return CORE_RWLOCK_SUCCESSFUL;
|
return CORE_RWLOCK_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user