summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/include/rtems/rtems/ratemon.h5
-rw-r--r--cpukit/rtems/include/rtems/rtems/ratemonimpl.h12
-rw-r--r--cpukit/rtems/src/ratemoncancel.c13
-rw-r--r--cpukit/rtems/src/ratemoncreate.c2
-rw-r--r--cpukit/rtems/src/ratemongetstatistics.c6
-rw-r--r--cpukit/rtems/src/ratemongetstatus.c8
-rw-r--r--cpukit/rtems/src/ratemonperiod.c17
-rw-r--r--cpukit/rtems/src/ratemonresetstatistics.c6
-rw-r--r--cpukit/rtems/src/ratemontimeout.c4
9 files changed, 36 insertions, 37 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 3203eab394..a2df13f025 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -194,6 +194,11 @@ typedef struct {
/** This field is the object management portion of a Period instance. */
Objects_Control Object;
+ /**
+ * @brief Protects the rate monotonic period state.
+ */
+ ISR_LOCK_MEMBER( Lock )
+
/** This is the timer used to provide the unblocking mechanism. */
Watchdog_Control Timer;
diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
index 9963cab612..b6b3ffd404 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
@@ -69,19 +69,19 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
}
RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Rate_monotonic_Control *the_period,
+ ISR_lock_Context *lock_context
)
{
- _Thread_Wait_acquire_default_critical( the_thread, lock_context );
+ _ISR_lock_Acquire( &the_period->Lock, lock_context );
}
RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
- Thread_Control *the_thread,
- ISR_lock_Context *lock_context
+ Rate_monotonic_Control *the_period,
+ ISR_lock_Context *lock_context
)
{
- _Thread_Wait_release_default( the_thread, lock_context );
+ _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context );
}
RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c
index 41ba48856f..b4e899d296 100644
--- a/cpukit/rtems/src/ratemoncancel.c
+++ b/cpukit/rtems/src/ratemoncancel.c
@@ -28,18 +28,17 @@ void _Rate_monotonic_Cancel(
)
{
Per_CPU_Control *cpu_self;
+ Thread_Control *update_priority;
- _Watchdog_Per_CPU_remove_relative( &the_period->Timer );
+ _Rate_monotonic_Acquire_critical( the_period, lock_context );
- owner = the_period->owner;
- _Rate_monotonic_Acquire_critical( owner, lock_context );
+ _Watchdog_Per_CPU_remove_relative( &the_period->Timer );
the_period->state = RATE_MONOTONIC_INACTIVE;
+ update_priority = _Scheduler_Cancel_job( the_period->owner );
cpu_self = _Thread_Dispatch_disable_critical( lock_context );
- _Rate_monotonic_Release( owner, lock_context );
-
- _Scheduler_Cancel_job( owner );
-
+ _Rate_monotonic_Release( the_period, lock_context );
+ _Thread_Update_priority( update_priority );
_Thread_Dispatch_enable( cpu_self );
}
diff --git a/cpukit/rtems/src/ratemoncreate.c b/cpukit/rtems/src/ratemoncreate.c
index 1a5c9b2615..a86c6a1eeb 100644
--- a/cpukit/rtems/src/ratemoncreate.c
+++ b/cpukit/rtems/src/ratemoncreate.c
@@ -62,6 +62,8 @@ rtems_status_code rtems_rate_monotonic_create(
return RTEMS_TOO_MANY;
}
+ _ISR_lock_Initialize( &the_period->Lock, "Rate Monotonic Period" );
+
the_period->owner = _Thread_Get_executing();
the_period->state = RATE_MONOTONIC_INACTIVE;
diff --git a/cpukit/rtems/src/ratemongetstatistics.c b/cpukit/rtems/src/ratemongetstatistics.c
index a6a0525fb0..7ffd2c5f5e 100644
--- a/cpukit/rtems/src/ratemongetstatistics.c
+++ b/cpukit/rtems/src/ratemongetstatistics.c
@@ -28,7 +28,6 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
{
Rate_monotonic_Control *the_period;
ISR_lock_Context lock_context;
- Thread_Control *owner;
const Rate_monotonic_Statistics *src;
if ( dst == NULL ) {
@@ -40,8 +39,7 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
return RTEMS_INVALID_ID;
}
- owner = the_period->owner;
- _Rate_monotonic_Acquire_critical( owner, &lock_context );
+ _Rate_monotonic_Acquire_critical( the_period, &lock_context );
src = &the_period->Statistics;
dst->count = src->count;
@@ -53,6 +51,6 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
_Timestamp_To_timespec( &src->max_wall_time, &dst->max_wall_time );
_Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time );
- _Rate_monotonic_Release( owner, &lock_context );
+ _Rate_monotonic_Release( the_period, &lock_context );
return RTEMS_SUCCESSFUL;
}
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;
}
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:
diff --git a/cpukit/rtems/src/ratemonresetstatistics.c b/cpukit/rtems/src/ratemonresetstatistics.c
index b146e6acb2..0b0e6c6369 100644
--- a/cpukit/rtems/src/ratemonresetstatistics.c
+++ b/cpukit/rtems/src/ratemonresetstatistics.c
@@ -26,16 +26,14 @@ rtems_status_code rtems_rate_monotonic_reset_statistics(
{
Rate_monotonic_Control *the_period;
ISR_lock_Context lock_context;
- Thread_Control *owner;
the_period = _Rate_monotonic_Get( id, &lock_context );
if ( the_period == NULL ) {
return RTEMS_INVALID_ID;
}
- owner = the_period->owner;
- _Rate_monotonic_Acquire_critical( owner, &lock_context );
+ _Rate_monotonic_Acquire_critical( the_period, &lock_context );
_Rate_monotonic_Reset_statistics( the_period );
- _Rate_monotonic_Release( owner, &lock_context );
+ _Rate_monotonic_Release( the_period, &lock_context );
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c
index bd38153b82..e514a314b3 100644
--- a/cpukit/rtems/src/ratemontimeout.c
+++ b/cpukit/rtems/src/ratemontimeout.c
@@ -31,7 +31,7 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
owner = the_period->owner;
_ISR_lock_ISR_disable( &lock_context );
- _Rate_monotonic_Acquire_critical( owner, &lock_context );
+ _Rate_monotonic_Acquire_critical( the_period, &lock_context );
wait_flags = _Thread_Wait_flags_get( owner );
if (
@@ -63,6 +63,6 @@ void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
}
} else {
the_period->state = RATE_MONOTONIC_EXPIRED;
- _Rate_monotonic_Release( owner, &lock_context );
+ _Rate_monotonic_Release( the_period, &lock_context );
}
}