From 7eef54e1ff5f705204cadbe50670bf06a3667a4b Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 26 Jul 2010 13:49:01 +0000 Subject: 2010-07-26 Joel Sherrill * rtems/src/ratemonperiod.c: Use if not switch since all cases of enum are not valid and switch was generating dead code. --- cpukit/rtems/src/ratemonperiod.c | 159 +++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 82 deletions(-) (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index eea939ee7c..47023041b4 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -1,7 +1,7 @@ /* * Rate Monotonic Manager - Period Blocking and Status * - * COPYRIGHT (c) 1989-2009. + * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -280,94 +280,89 @@ rtems_status_code rtems_rate_monotonic_period( } _ISR_Disable( level ); - switch ( the_period->state ) { - case RATE_MONOTONIC_INACTIVE: { + if ( the_period->state == RATE_MONOTONIC_INACTIVE ) { + _ISR_Enable( level ); - _ISR_Enable( level ); + /* + * Baseline statistics information for the beginning of a period. + */ + _Rate_monotonic_Initiate_statistics( the_period ); - /* - * Baseline statistics information for the beginning of a period. - */ - _Rate_monotonic_Initiate_statistics( the_period ); + the_period->state = RATE_MONOTONIC_ACTIVE; + _Watchdog_Initialize( + &the_period->Timer, + _Rate_monotonic_Timeout, + id, + NULL + ); - the_period->state = RATE_MONOTONIC_ACTIVE; - _Watchdog_Initialize( - &the_period->Timer, - _Rate_monotonic_Timeout, - id, - NULL - ); - - the_period->next_length = length; - - _Watchdog_Insert_ticks( &the_period->Timer, length ); - _Thread_Enable_dispatch(); - return RTEMS_SUCCESSFUL; - } - case RATE_MONOTONIC_ACTIVE: - - /* - * Update statistics from the concluding period. - */ - _Rate_monotonic_Update_statistics( the_period ); - - /* - * This tells the _Rate_monotonic_Timeout that this task is - * in the process of blocking on the period and that we - * may be changing the length of the next period. - */ - the_period->state = RATE_MONOTONIC_OWNER_IS_BLOCKING; - the_period->next_length = length; - - _ISR_Enable( level ); - - _Thread_Executing->Wait.id = the_period->Object.id; - _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD ); - - /* - * Did the watchdog timer expire while we were actually blocking - * on it? - */ - _ISR_Disable( level ); - local_state = the_period->state; - the_period->state = RATE_MONOTONIC_ACTIVE; - _ISR_Enable( level ); - - /* - * If it did, then we want to unblock ourself and continue as - * if nothing happen. The period was reset in the timeout routine. - */ - if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) - _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD ); - - _Thread_Enable_dispatch(); - return RTEMS_SUCCESSFUL; - break; - - case RATE_MONOTONIC_EXPIRED: - - /* - * Update statistics from the concluding period - */ - _Rate_monotonic_Update_statistics( the_period ); - - _ISR_Enable( level ); + the_period->next_length = length; + + _Watchdog_Insert_ticks( &the_period->Timer, length ); + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + if ( the_period->state == RATE_MONOTONIC_ACTIVE ) { + /* + * Update statistics from the concluding period. + */ + _Rate_monotonic_Update_statistics( the_period ); + + /* + * This tells the _Rate_monotonic_Timeout that this task is + * in the process of blocking on the period and that we + * may be changing the length of the next period. + */ + the_period->state = RATE_MONOTONIC_OWNER_IS_BLOCKING; + the_period->next_length = length; + + _ISR_Enable( level ); + + _Thread_Executing->Wait.id = the_period->Object.id; + _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD ); + + /* + * Did the watchdog timer expire while we were actually blocking + * on it? + */ + _ISR_Disable( level ); + local_state = the_period->state; the_period->state = RATE_MONOTONIC_ACTIVE; - the_period->next_length = length; - - _Watchdog_Insert_ticks( &the_period->Timer, length ); - _Thread_Enable_dispatch(); - return RTEMS_TIMEOUT; - - case RATE_MONOTONIC_OWNER_IS_BLOCKING: - case RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING: - /* - * These should never happen. - */ - break; + _ISR_Enable( level ); + + /* + * If it did, then we want to unblock ourself and continue as + * if nothing happen. The period was reset in the timeout routine. + */ + if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) + _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD ); + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; } + if ( the_period->state == RATE_MONOTONIC_EXPIRED ) { + /* + * Update statistics from the concluding period + */ + _Rate_monotonic_Update_statistics( the_period ); + + _ISR_Enable( level ); + + the_period->state = RATE_MONOTONIC_ACTIVE; + the_period->next_length = length; + + _Watchdog_Insert_ticks( &the_period->Timer, length ); + _Thread_Enable_dispatch(); + return RTEMS_TIMEOUT; + } + + /* + * These should never happen so just return invalid Id. + * - RATE_MONOTONIC_OWNER_IS_BLOCKING: + * - RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING: + */ #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: /* should never return this */ #endif -- cgit v1.2.3