diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-23 10:01:22 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-05-19 12:00:45 +0200 |
commit | 02c4c441a51b43b55608893efa4a80a62bb9d4d5 (patch) | |
tree | 709655b1c53afc3ff981890989a5290d1c400ad2 /cpukit/score/src/coresemseize.c | |
parent | score: Generalize _Event_Timeout() (diff) | |
download | rtems-02c4c441a51b43b55608893efa4a80a62bb9d4d5.tar.bz2 |
score: Add Thread_queue_Control::Lock
Move the complete thread queue enqueue procedure into
_Thread_queue_Enqueue_critical(). It is possible to use the thread
queue lock to protect state of the object embedding the thread queue.
This enables per object fine grained locking in the future.
Delete _Thread_queue_Enter_critical_section().
Update #2273.
Diffstat (limited to 'cpukit/score/src/coresemseize.c')
-rw-r--r-- | cpukit/score/src/coresemseize.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c index 9c0db96204..d7ab28e779 100644 --- a/cpukit/score/src/coresemseize.c +++ b/cpukit/score/src/coresemseize.c @@ -34,13 +34,13 @@ void _CORE_semaphore_Seize( Watchdog_Interval timeout ) { - ISR_Level level; + ISR_lock_Context lock_context; executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL; - _ISR_Disable( level ); + _Thread_queue_Acquire( &the_semaphore->Wait_queue, &lock_context ); if ( the_semaphore->count != 0 ) { the_semaphore->count -= 1; - _ISR_Enable( level ); + _Thread_queue_Release( &the_semaphore->Wait_queue, &lock_context ); return; } @@ -50,7 +50,7 @@ void _CORE_semaphore_Seize( * the semaphore was not available and the caller never blocked. */ if ( !wait ) { - _ISR_Enable( level ); + _Thread_queue_Release( &the_semaphore->Wait_queue, &lock_context ); executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; return; } @@ -59,15 +59,13 @@ void _CORE_semaphore_Seize( * If the semaphore is not available and the caller is willing to * block, then we now block the caller with optional 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( + executing->Wait.id = id; + _Thread_queue_Enqueue_critical( &the_semaphore->Wait_queue, executing, STATES_WAITING_FOR_SEMAPHORE, - timeout + timeout, + &lock_context ); } #endif |