diff options
author | Glenn Humphrey <glenn.humphrey@oarcorp.com> | 2007-11-06 19:52:36 +0000 |
---|---|---|
committer | Glenn Humphrey <glenn.humphrey@oarcorp.com> | 2007-11-06 19:52:36 +0000 |
commit | 8a8f5b263ae4a42b85a2d0c4a598b9702e04a57e (patch) | |
tree | 8ee935170b0b7bb403d9be6082cdaff91adb9063 /cpukit/score/src | |
parent | 2007-11-06 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-8a8f5b263ae4a42b85a2d0c4a598b9702e04a57e.tar.bz2 |
2007-11-06 Glenn Humphrey <glenn.humphrey@OARcorp.com>
Miscellaneous changes made after a review against the POSIX spec.
* posix/src/pbarrierinit.c, posix/src/prwlockinit.c: If the caller
passes a NULL in the attributes parameter, default attributes are used.
* posix/src/prwlockdestroy.c: If there is at least one thread
waiting, do not allow deletion.
* posix/src/prwlockwrlock.c: Corrected parameter passed to the core
operation used to obtain a RWLock for writing.
* posix/src/pspinlocktranslatereturncode.c,
score/include/rtems/score/corespinlock.h,
score/src/corespinlockrelease.c: If the current thread is not the
holder of the lock, do not allow an unlock and return EPERM.
* score/src/corerwlockobtainwrite.c: Corrected to use the operation
for queueing with a timeout handler.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/corerwlockobtainwrite.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/corespinlockrelease.c | 21 |
2 files changed, 26 insertions, 2 deletions
diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c index 02e7906249..a1535b786f 100644 --- a/cpukit/score/src/corerwlockobtainwrite.c +++ b/cpukit/score/src/corerwlockobtainwrite.c @@ -87,7 +87,12 @@ void _CORE_RWLock_Obtain_for_writing( executing->Wait.return_code = CORE_RWLOCK_SUCCESSFUL; _ISR_Enable( level ); - _Thread_queue_Enqueue( &the_rwlock->Wait_queue, timeout ); + _Thread_queue_Enqueue_with_handler( + &the_rwlock->Wait_queue, + timeout, + _CORE_RWLock_Timeout + ); + /* return to API level so it can dispatch and we block */ } diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c index 05aec32c4c..46aa7c1105 100644 --- a/cpukit/score/src/corespinlockrelease.c +++ b/cpukit/score/src/corespinlockrelease.c @@ -30,7 +30,10 @@ * Input parameters: * the_spinlock - the spinlock control block to initialize * - * Output parameters: NONE + * Output parameters: + * CORE_SPINLOCK_SUCCESSFUL - if successful + * error code - if unsuccessful + * */ CORE_spinlock_Status _CORE_spinlock_Release( @@ -40,14 +43,30 @@ CORE_spinlock_Status _CORE_spinlock_Release( ISR_Level level; _ISR_Disable( level ); + + /* + * It must locked before it can be unlocked. + */ if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) { _ISR_Enable( level ); return CORE_SPINLOCK_NOT_LOCKED; } + + /* + * It must locked by the current thread before it can be unlocked. + */ + if ( the_spinlock->holder != _Thread_Executing->Object.id ) { + _ISR_Enable( level ); + return CORE_SPINLOCK_NOT_HOLDER; + } + /* + * Let it be unlocked. + */ the_spinlock->users -= 1; the_spinlock->lock = CORE_SPINLOCK_UNLOCKED; the_spinlock->holder = 0; + _ISR_Enable( level ); return CORE_SPINLOCK_SUCCESSFUL; } |