diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-20 09:45:10 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-04-21 08:25:32 +0200 |
commit | 1041de1ab071d126148f0c02e5da0db637001f1c (patch) | |
tree | 07c077b044a14d2abca32e8f9a453eec1141431e /cpukit/score/include/rtems/score/threadimpl.h | |
parent | score: Modify _Thread_Dispatch_disable_critical() (diff) | |
download | rtems-1041de1ab071d126148f0c02e5da0db637001f1c.tar.bz2 |
score: Add _Thread_Get_interrupt_disable()
Remove _Thread_Acquire() and _Thread_Acquire_for_executing(). Add
utility functions for the default thread lock. Use the default thread
lock for the RTEMS events. There is no need to disable thread
dispatching and a Giant acquire in _Event_Timeout() since this was
already done by the caller.
Update #2273.
Diffstat (limited to 'cpukit/score/include/rtems/score/threadimpl.h')
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 88 |
1 files changed, 78 insertions, 10 deletions
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 1ccc4d6c50..84c9ac316f 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -22,6 +22,7 @@ #define _RTEMS_SCORE_THREADIMPL_H #include <rtems/score/thread.h> +#include <rtems/score/assert.h> #include <rtems/score/chainimpl.h> #include <rtems/score/interr.h> #include <rtems/score/isr.h> @@ -382,23 +383,16 @@ Thread_Control *_Thread_Get ( ); /** - * @brief Acquires a thread by its identifier. + * @brief Gets a thread by its identifier. * - * @see _Objects_Acquire(). + * @see _Objects_Get_isr_disable(). */ -Thread_Control *_Thread_Acquire( +Thread_Control *_Thread_Get_interrupt_disable( Objects_Id id, Objects_Locations *location, ISR_lock_Context *lock_context ); -/** - * @brief Acquires the executing thread. - * - * @see _Objects_Acquire(). - */ -Thread_Control *_Thread_Acquire_executing( ISR_lock_Context *lock_context ); - RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU( const Thread_Control *thread ) @@ -866,6 +860,80 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( } /** + * @brief Acquires the default thread lock and returns the executing thread. + * + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @return The executing thread. + * + * @see _Thread_Lock_release_default(). + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Lock_acquire_default_for_executing( + ISR_lock_Context *lock_context +) +{ + Thread_Control *executing; + + _ISR_lock_ISR_disable( lock_context ); + executing = _Thread_Executing; + _ISR_lock_Acquire( &executing->Lock.Default, lock_context ); + + return executing; +} + +/** + * @brief Acquires the default thread lock inside a critical section + * (interrupts disabled). + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @see _Thread_Lock_release_default(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Lock_acquire_default_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _Assert( _ISR_Get_level() != 0 ); + _ISR_lock_Acquire( &the_thread->Lock.Default, lock_context ); +} + +/** + * @brief Acquires the default thread lock. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @see _Thread_Lock_release_default(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Lock_acquire_default( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable_and_acquire( &the_thread->Lock.Default, lock_context ); +} + +/** + * @brief Release the default thread lock. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * acquire. + */ +RTEMS_INLINE_ROUTINE void _Thread_Lock_release_default( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release_and_ISR_enable( &the_thread->Lock.Default, lock_context ); +} + +/** * @brief Release the thread lock. * * @param[in] lock The lock returned by _Thread_Lock_acquire(). |