diff options
Diffstat (limited to 'cpukit/rtems/src/ratemonperiod.c')
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index 2c55eb089d..bc2051a4e4 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,12 +12,29 @@ /* * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. + * Copyright (c) 2016 embedded brains GmbH & Co. KG * COPYRIGHT (c) 2016 Kuan-Hsun Chen. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -26,7 +45,7 @@ #include <rtems/score/schedulerimpl.h> #include <rtems/score/todimpl.h> -bool _Rate_monotonic_Get_status( +void _Rate_monotonic_Get_status( const Rate_monotonic_Control *the_period, Timestamp_Control *wall_since_last_period, Timestamp_Control *cpu_since_last_period @@ -47,14 +66,7 @@ bool _Rate_monotonic_Get_status( /* * Determine cpu usage since period initiated. */ - _Thread_Get_CPU_time_used( owning_thread, &used ); - - /* - * The cpu usage info was reset while executing. Can't - * determine a status. - */ - if ( _Timestamp_Less_than( &used, &the_period->cpu_usage_period_initiated ) ) - return false; + used = _Thread_Get_CPU_time_used( owning_thread ); /* used = current cpu usage - cpu usage at start of period */ _Timestamp_Subtract( @@ -62,8 +74,6 @@ bool _Rate_monotonic_Get_status( &used, cpu_since_last_period ); - - return true; } static void _Rate_monotonic_Release_postponed_job( @@ -130,7 +140,7 @@ void _Rate_monotonic_Restart( * Set the starting point and the CPU time used for the statistics. */ _TOD_Get_uptime( &the_period->time_period_initiated ); - _Thread_Get_CPU_time_used( owner, &the_period->cpu_usage_period_initiated ); + the_period->cpu_usage_period_initiated = _Thread_Get_CPU_time_used( owner ); _Rate_monotonic_Release_job( the_period, @@ -147,7 +157,6 @@ static void _Rate_monotonic_Update_statistics( Timestamp_Control executed; Timestamp_Control since_last_period; Rate_monotonic_Statistics *stats; - bool valid_status; /* * Assume we are only called in states where it is appropriate @@ -167,10 +176,7 @@ static void _Rate_monotonic_Update_statistics( /* * Grab status for time statistics. */ - valid_status = - _Rate_monotonic_Get_status( the_period, &since_last_period, &executed ); - if (!valid_status) - return; + _Rate_monotonic_Get_status( the_period, &since_last_period, &executed ); /* * Update CPU time @@ -217,7 +223,7 @@ static rtems_status_code _Rate_monotonic_Activate( ISR_lock_Context *lock_context ) { - the_period->postponed_jobs = 0; + _Assert( the_period->postponed_jobs == 0 ); the_period->state = RATE_MONOTONIC_ACTIVE; the_period->next_length = length; _Rate_monotonic_Restart( the_period, executing, lock_context ); @@ -260,7 +266,7 @@ static rtems_status_code _Rate_monotonic_Block_while_active( ); if ( !success ) { _Assert( - _Thread_Wait_flags_get( executing ) == RATE_MONOTONIC_READY_AGAIN + _Thread_Wait_flags_get( executing ) == THREAD_WAIT_STATE_READY ); _Thread_Unblock( executing ); } |