diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-21 15:01:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-22 07:05:05 +0100 |
commit | 90960bd11a91259d9aace3870692dbe2e227de0f (patch) | |
tree | 3d88f8bc3d1fe17252e8290cadae2afb4a38ce4b /cpukit/rtems/include/rtems/rtems/ratemonimpl.h | |
parent | rtems: Avoid __RTEMS_USE_TICKS_FOR_STATISTICS__ (diff) | |
download | rtems-90960bd11a91259d9aace3870692dbe2e227de0f.tar.bz2 |
rtems: Rework rate-monotonic scheduler
Use the default thread lock to protect rate-monotonic state changes.
This avoids use of the Giant lock. Split rtems_rate_monotonic_period()
body into several static functions. Introduce a new thread wait class
THREAD_WAIT_CLASS_PERIOD for period objects to synchronize the blocking
operation.
Close #2631.
Diffstat (limited to 'cpukit/rtems/include/rtems/rtems/ratemonimpl.h')
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/ratemonimpl.h | 113 |
1 files changed, 35 insertions, 78 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h index 3141bfa9ae..28837a2c16 100644 --- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h +++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h @@ -8,6 +8,7 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). + * Copyright (c) 2016 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -19,6 +20,9 @@ #include <rtems/rtems/ratemon.h> #include <rtems/score/objectimpl.h> +#include <rtems/score/schedulerimpl.h> +#include <rtems/score/threadimpl.h> +#include <rtems/score/watchdogimpl.h> #include <string.h> @@ -34,6 +38,15 @@ extern "C" { * @{ */ +#define RATE_MONOTONIC_INTEND_TO_BLOCK \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_INTEND_TO_BLOCK ) + +#define RATE_MONOTONIC_BLOCKED \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED ) + +#define RATE_MONOTONIC_READY_AGAIN \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_READY_AGAIN ) + /** * @brief Rate Monotonic Period Class Management Structure * @@ -55,86 +68,31 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void ) _Objects_Allocate( &_Rate_monotonic_Information ); } -/** - * @brief Allocates a period control block from - * the inactive chain of free period control blocks. - * - * This routine allocates a period control block from - * the inactive chain of free period control blocks. - */ -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Free ( - Rate_monotonic_Control *the_period +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context ) { - _Objects_Free( &_Rate_monotonic_Information, &the_period->Object ); + _Thread_Lock_acquire_default_critical( the_thread, lock_context ); } -/** - * @brief Maps period IDs to period control blocks. - * - * This function maps period IDs to period control blocks. - * If ID corresponds to a local period, then it returns - * the_period control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. Otherwise, location is set - * to OBJECTS_ERROR and the_period is undefined. - */ -RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get ( - Objects_Id id, - Objects_Locations *location +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release( + Thread_Control *the_thread, + ISR_lock_Context *lock_context ) { - return (Rate_monotonic_Control *) - _Objects_Get( &_Rate_monotonic_Information, id, location ); + _Thread_Lock_release_default( the_thread, lock_context ); } -/** - * @brief Checks if the_period is in the ACTIVE state. - * - * This function returns TRUE if the_period is in the ACTIVE state, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_active ( - Rate_monotonic_Control *the_period +RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( + Objects_Id id, + ISR_lock_Context *lock_context ) { - return (the_period->state == RATE_MONOTONIC_ACTIVE); -} - -/** - * @brief Checks if the_period is in the ACTIVE state. - * - * This function returns TRUE if the_period is in the ACTIVE state, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_inactive ( - Rate_monotonic_Control *the_period -) -{ - return (the_period->state == RATE_MONOTONIC_INACTIVE); -} - -/** - * @brief Checks if the_period is in the EXPIRED state. - * - * This function returns TRUE if the_period is in the EXPIRED state, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_expired ( - Rate_monotonic_Control *the_period -) -{ - return (the_period->state == RATE_MONOTONIC_EXPIRED); + return (Rate_monotonic_Control *) + _Objects_Get_local( &_Rate_monotonic_Information, id, lock_context ); } -/** - * @brief Rate Monotonic Timeout - * - * This routine is invoked when the period represented by the watchdog expires. - * If the thread which owns this period is blocked waiting for the period to - * expire, then it is readied and the period is restarted. If the owning thread - * is not waiting for the period to expire, then the period is placed in the - * EXPIRED state and not restarted. - */ void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); /** @@ -158,17 +116,16 @@ bool _Rate_monotonic_Get_status( Timestamp_Control *cpu_since_last_period ); -/** - * @brief Restart Rate Monotonic Period - * - * This routine is invoked when a period is initiated via an explicit - * call to rtems_rate_monotonic_period for the period's first iteration - * or from _Rate_monotonic_Timeout for period iterations 2-n. - * - * @param[in] the_period points to the period being operated upon. - */ void _Rate_monotonic_Restart( - Rate_monotonic_Control *the_period + Rate_monotonic_Control *the_period, + Thread_Control *owner, + ISR_lock_Context *lock_context +); + +void _Rate_monotonic_Cancel( + Rate_monotonic_Control *the_period, + Thread_Control *owner, + ISR_lock_Context *lock_context ); RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time( |