From ee0e41355d1faa5f74085effc4f57c3a7fc1f884 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 4 Aug 2016 10:20:29 +0200 Subject: 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. --- cpukit/rtems/src/ratemongetstatus.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'cpukit/rtems/src/ratemongetstatus.c') diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c index 82a950ec6a..403c6ed097 100644 --- a/cpukit/rtems/src/ratemongetstatus.c +++ b/cpukit/rtems/src/ratemongetstatus.c @@ -28,7 +28,6 @@ rtems_status_code rtems_rate_monotonic_get_status( { Rate_monotonic_Control *the_period; ISR_lock_Context lock_context; - Thread_Control *owner; rtems_status_code status; if ( period_status == NULL ) { @@ -40,10 +39,9 @@ rtems_status_code rtems_rate_monotonic_get_status( return RTEMS_INVALID_ID; } - owner = the_period->owner; - _Rate_monotonic_Acquire_critical( owner, &lock_context ); + _Rate_monotonic_Acquire_critical( the_period, &lock_context ); - period_status->owner = owner->Object.id; + period_status->owner = the_period->owner->Object.id; period_status->state = the_period->state; if ( the_period->state == RATE_MONOTONIC_INACTIVE ) { @@ -81,6 +79,6 @@ rtems_status_code rtems_rate_monotonic_get_status( } } - _Rate_monotonic_Release( owner, &lock_context ); + _Rate_monotonic_Release( the_period, &lock_context ); return status; } -- cgit v1.2.3