diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-05-28 13:37:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-06-03 08:15:16 +0200 |
commit | 6c7caa1a9e1587dcc069aa811e9086c220b03ea8 (patch) | |
tree | 5470465893d892e0f0caffd3033e7b6efe68c508 | |
parent | score: Add Resource Handler (diff) | |
download | rtems-6c7caa1a9e1587dcc069aa811e9086c220b03ea8.tar.bz2 |
score: Add and use _Thread_Owns_resources()
-rw-r--r-- | cpukit/posix/src/pthread.c | 4 | ||||
-rw-r--r-- | cpukit/rtems/src/tasksetpriority.c | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadimpl.h | 17 | ||||
-rw-r--r-- | cpukit/score/src/coremutexsurrender.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/threadrestart.c | 2 |
5 files changed, 22 insertions, 5 deletions
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index ab197f3a51..6b1e55549b 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -115,7 +115,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( printk( "TSR %d %d %d\n", the_thread->resource_count, the_thread->current_priority, new_priority ); #endif - if ( the_thread->resource_count == 0 ) { + if ( !_Thread_Owns_resources( the_thread ) ) { /* * If this would make them less important, then do not change it. */ @@ -161,7 +161,7 @@ void _POSIX_Threads_Sporadic_budget_callout( printk( "callout %d %d %d\n", the_thread->resource_count, the_thread->current_priority, new_priority ); #endif - if ( the_thread->resource_count == 0 ) { + if ( !_Thread_Owns_resources( the_thread ) ) { /* * Make sure we are actually lowering it. If they have lowered it * to logically lower than sched_ss_low_priority, then we do not want to diff --git a/cpukit/rtems/src/tasksetpriority.c b/cpukit/rtems/src/tasksetpriority.c index c7b0556c17..4e4835675d 100644 --- a/cpukit/rtems/src/tasksetpriority.c +++ b/cpukit/rtems/src/tasksetpriority.c @@ -48,7 +48,7 @@ rtems_status_code rtems_task_set_priority( the_thread->real_priority = _RTEMS_tasks_Priority_to_Core( new_priority ); - if ( the_thread->resource_count == 0 || + if ( !_Thread_Owns_resources( the_thread ) || the_thread->current_priority > new_priority ) _Thread_Change_priority( the_thread, new_priority, false ); } diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index 5e7660503a..8b91730d34 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -785,6 +785,23 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing( return ( life_state & THREAD_LIFE_RESTARTING_TERMINATING ) != 0; } +/** + * @brief Returns true if the thread owns resources, and false otherwise. + * + * Resources are accounted with the Thread_Control::resource_count resource + * counter. This counter is used by semaphore objects for example. + * + * @param[in] the_thread The thread. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( + const Thread_Control *the_thread +) +{ + bool owns_resources = the_thread->resource_count != 0; + + return owns_resources; +} + RTEMS_INLINE_ROUTINE void _Thread_Debug_set_real_processor( Thread_Control *the_thread, Per_CPU_Control *cpu diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index fff3cd74da..7a7a047f39 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -167,7 +167,7 @@ CORE_mutex_Status _CORE_mutex_Surrender( * inherited priority must be lowered if this is the last * mutex (i.e. resource) this task has. */ - if ( holder->resource_count == 0 && + if ( !_Thread_Owns_resources( holder ) && holder->real_priority != holder->current_priority ) { _Thread_Change_priority( holder, holder->real_priority, true ); } diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 5c527d8a63..c65ef9a21b 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -47,7 +47,7 @@ static void _Thread_Make_zombie( Thread_Control *the_thread ) ISR_lock_Context lock_context; Thread_Zombie_control *zombies = &_Thread_Zombies; - if ( the_thread->resource_count != 0 ) { + if ( _Thread_Owns_resources( the_thread ) ) { _Terminate( INTERNAL_ERROR_CORE, false, |