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/score/src | |
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/score/src')
-rw-r--r-- | cpukit/score/src/schedulercbsunblock.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/threadchangepriority.c | 4 | ||||
-rw-r--r-- | cpukit/score/src/threadclearstate.c | 4 | ||||
-rw-r--r-- | cpukit/score/src/threadgetcputimeused.c | 11 | ||||
-rw-r--r-- | cpukit/score/src/threadsetstate.c | 4 | ||||
-rw-r--r-- | cpukit/score/src/threadyield.c | 4 |
6 files changed, 22 insertions, 12 deletions
diff --git a/cpukit/score/src/schedulercbsunblock.c b/cpukit/score/src/schedulercbsunblock.c index 9170889491..7898588bf2 100644 --- a/cpukit/score/src/schedulercbsunblock.c +++ b/cpukit/score/src/schedulercbsunblock.c @@ -56,7 +56,12 @@ Scheduler_Void_or_thread _Scheduler_CBS_Unblock( the_thread->real_priority = new_priority; if ( the_thread->current_priority != new_priority ) { the_thread->current_priority = new_priority; - _Scheduler_Change_priority(the_thread, new_priority, true); + _Scheduler_EDF_Change_priority( + scheduler, + the_thread, + new_priority, + true + ); } } } diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 35e5e5bfbc..152646f52f 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -64,7 +64,7 @@ void _Thread_Change_priority( _Thread_Lock_release( lock, &lock_context ); - _Scheduler_Acquire( the_thread, &lock_context ); + _Thread_State_acquire( the_thread, &lock_context ); if ( the_thread->priority_generation == my_generation ) { if ( _States_Is_ready( the_thread->current_state ) ) { @@ -78,7 +78,7 @@ void _Thread_Change_priority( } } - _Scheduler_Release( the_thread, &lock_context ); + _Thread_State_release( the_thread, &lock_context ); } else { _Thread_Lock_release( lock, &lock_context ); } diff --git a/cpukit/score/src/threadclearstate.c b/cpukit/score/src/threadclearstate.c index ae54e3aac1..3da3538551 100644 --- a/cpukit/score/src/threadclearstate.c +++ b/cpukit/score/src/threadclearstate.c @@ -32,7 +32,7 @@ States_Control _Thread_Clear_state( _Assert( state != 0 ); - _Scheduler_Acquire( the_thread, &lock_context ); + _Thread_State_acquire( the_thread, &lock_context ); previous_state = the_thread->current_state; @@ -47,7 +47,7 @@ States_Control _Thread_Clear_state( } } - _Scheduler_Release( the_thread, &lock_context ); + _Thread_State_release( the_thread, &lock_context ); return previous_state; } diff --git a/cpukit/score/src/threadgetcputimeused.c b/cpukit/score/src/threadgetcputimeused.c index 6bfe8ea216..9026007cf0 100644 --- a/cpukit/score/src/threadgetcputimeused.c +++ b/cpukit/score/src/threadgetcputimeused.c @@ -33,9 +33,13 @@ void _Thread_Get_CPU_time_used( Timestamp_Control *cpu_time_used ) { - ISR_lock_Context lock_context; + const Scheduler_Control *scheduler; + ISR_lock_Context state_lock_context; + ISR_lock_Context scheduler_lock_context; - _Scheduler_Acquire( the_thread, &lock_context ); + _Thread_State_acquire( the_thread, &state_lock_context ); + scheduler = _Scheduler_Get( the_thread ); + _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context ); if ( _Thread_Is_scheduled( the_thread ) ) { _Thread_Update_CPU_time_used( the_thread, _Thread_Get_CPU( the_thread ) ); @@ -43,5 +47,6 @@ void _Thread_Get_CPU_time_used( *cpu_time_used = 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 ); } diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c index 51128279b1..3aaa463f97 100644 --- a/cpukit/score/src/threadsetstate.c +++ b/cpukit/score/src/threadsetstate.c @@ -36,7 +36,7 @@ States_Control _Thread_Set_state( _Assert( state != 0 ); - _Scheduler_Acquire( the_thread, &lock_context ); + _Thread_State_acquire( the_thread, &lock_context ); previous_state = the_thread->current_state; next_state = _States_Set( state, previous_state); @@ -46,7 +46,7 @@ States_Control _Thread_Set_state( _Scheduler_Block( the_thread ); } - _Scheduler_Release( the_thread, &lock_context ); + _Thread_State_release( the_thread, &lock_context ); return previous_state; } diff --git a/cpukit/score/src/threadyield.c b/cpukit/score/src/threadyield.c index 7f1c175b4a..cfd8118665 100644 --- a/cpukit/score/src/threadyield.c +++ b/cpukit/score/src/threadyield.c @@ -31,11 +31,11 @@ void _Thread_Yield( Thread_Control *executing ) { ISR_lock_Context lock_context; - _Scheduler_Acquire( executing, &lock_context ); + _Thread_State_acquire( executing, &lock_context ); if ( _States_Is_ready( executing->current_state ) ) { _Scheduler_Yield( executing ); } - _Scheduler_Release( executing, &lock_context ); + _Thread_State_release( executing, &lock_context ); } |