diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-08-04 10:20:29 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-08-04 10:20:29 +0200 |
commit | ee0e41355d1faa5f74085effc4f57c3a7fc1f884 (patch) | |
tree | c845395523e084218ca6715977648b807d30605d /cpukit/rtems/src/ratemonperiod.c | |
parent | score: Fix _Thread_queue_Path_release() (diff) | |
download | rtems-ee0e41355d1faa5f74085effc4f57c3a7fc1f884.tar.bz2 |
score: Fix a release/cancel job race condition
Split up the potential thread priority change in the scheduler
release/cancel job operation. Protect the rate monotonic period state
with a dedicated SMP lock. This avoids a race condition during
_Rate_monotonic_Timeout() while _Rate_monotonic_Cancel() is called on
another processor.
Diffstat (limited to 'cpukit/rtems/src/ratemonperiod.c')
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index 303fe174e5..75a80d8088 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -71,21 +71,20 @@ static void _Rate_monotonic_Release_job( ) { Per_CPU_Control *cpu_self; - uint64_t deadline; + Thread_Control *update_priority; + uint64_t deadline; cpu_self = _Thread_Dispatch_disable_critical( lock_context ); - _Rate_monotonic_Release( owner, lock_context ); - _ISR_lock_ISR_disable( lock_context ); deadline = _Watchdog_Per_CPU_insert_relative( &the_period->Timer, cpu_self, next_length ); - _ISR_lock_ISR_enable( lock_context ); - - _Scheduler_Release_job( owner, deadline ); + update_priority = _Scheduler_Release_job( owner, deadline ); + _Rate_monotonic_Release( the_period, lock_context ); + _Thread_Update_priority( update_priority ); _Thread_Dispatch_enable( cpu_self ); } @@ -217,7 +216,7 @@ static rtems_status_code _Rate_monotonic_Block_while_active( _Thread_Wait_flags_set( executing, RATE_MONOTONIC_INTEND_TO_BLOCK ); cpu_self = _Thread_Dispatch_disable_critical( lock_context ); - _Rate_monotonic_Release( executing, lock_context ); + _Rate_monotonic_Release( the_period, lock_context ); _Thread_Set_state( executing, STATES_WAITING_FOR_PERIOD ); @@ -278,13 +277,13 @@ rtems_status_code rtems_rate_monotonic_period( return RTEMS_NOT_OWNER_OF_RESOURCE; } - _Rate_monotonic_Acquire_critical( executing, &lock_context ); + _Rate_monotonic_Acquire_critical( the_period, &lock_context ); state = the_period->state; if ( length == RTEMS_PERIOD_STATUS ) { status = _Rate_monotonic_Get_status_for_state( state ); - _Rate_monotonic_Release( executing, &lock_context ); + _Rate_monotonic_Release( the_period, &lock_context ); } else { switch ( state ) { case RATE_MONOTONIC_ACTIVE: |