diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-11 11:54:49 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-12 13:24:41 +0200 |
commit | bd12dda405e1bab16c522f7ef0dd2b455230d269 (patch) | |
tree | c644df77b8512e1e211bfae39587511d0774f0d8 /cpukit/libmisc/cpuuse/cpuusagereset.c | |
parent | rtems: Avoid Giant lock rtems_task_is_suspended() (diff) | |
download | rtems-bd12dda405e1bab16c522f7ef0dd2b455230d269.tar.bz2 |
score: Use thread state lock for current state
In addition protect scheduler of thread by thread state lock. Enables
use of scheduler per-instance locks.
Update #2555.
Diffstat (limited to 'cpukit/libmisc/cpuuse/cpuusagereset.c')
-rw-r--r-- | cpukit/libmisc/cpuuse/cpuusagereset.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cpukit/libmisc/cpuuse/cpuusagereset.c b/cpukit/libmisc/cpuuse/cpuusagereset.c index 6ef50f9b25..74f273aded 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereset.c +++ b/cpukit/libmisc/cpuuse/cpuusagereset.c @@ -28,11 +28,18 @@ static void CPU_usage_Per_thread_handler( Thread_Control *the_thread ) { - ISR_lock_Context lock_context; + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; + + _Thread_State_acquire( the_thread, &state_lock_context ); + scheduler = _Scheduler_Get( the_thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); - _Scheduler_Acquire( the_thread, &lock_context ); _Timestamp_Set_to_zero( &the_thread->cpu_time_used ); - _Scheduler_Release( the_thread, &lock_context ); + + _Scheduler_Release_critical( scheduler, &scheduler_lock_context ); + _Thread_State_release( the_thread, &state_lock_context ); } /* |