Changeset 11ab74e in rtems


Ignore:
Timestamp:
Dec 5, 1995, 3:27:51 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ca201c9
Parents:
8d0b7d96
Message:

new states added and _Rate_monotonic_Set_State removed.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/rtems/headers/ratemon.h

    r8d0b7d96 r11ab74e  
    4040
    4141typedef enum {
    42   RATE_MONOTONIC_INACTIVE,  /* off chain, never initialized */
    43   RATE_MONOTONIC_ACTIVE,    /* on chain, running continuously */
    44   RATE_MONOTONIC_EXPIRED    /* off chain, will be reset by next rm_period */
     42  RATE_MONOTONIC_INACTIVE,               /* off chain, never initialized */
     43  RATE_MONOTONIC_OWNER_IS_BLOCKING,      /* on chain, owner is blocking on it */
     44  RATE_MONOTONIC_ACTIVE,                 /* on chain, running continuously */
     45  RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, /* on chain, expired while owner was */
     46                                         /*   was blocking on it */
     47  RATE_MONOTONIC_EXPIRED                 /* off chain, will be reset by next */
     48                                         /*   rtems_rate_monotonic_period */
    4549}   Rate_Monotonic_Period_states;
    4650
     
    194198
    195199/*
    196  *  _Rate_monotonic_Set_state
    197  *
    198  *  DESCRIPTION:
    199  *
    200  *  This function blocks the calling task so that it is waiting for
    201  *  a period to expire.  It returns TRUE if the task was successfully
    202  *  blocked, and FALSE otherwise.
    203  */
    204 
    205 boolean _Rate_monotonic_Set_state(
    206   Rate_monotonic_Control *the_period
    207 );
    208 
    209 /*
    210200 *  _Rate_monotonic_Timeout
    211201 *
  • c/src/exec/rtems/include/rtems/rtems/ratemon.h

    r8d0b7d96 r11ab74e  
    4040
    4141typedef enum {
    42   RATE_MONOTONIC_INACTIVE,  /* off chain, never initialized */
    43   RATE_MONOTONIC_ACTIVE,    /* on chain, running continuously */
    44   RATE_MONOTONIC_EXPIRED    /* off chain, will be reset by next rm_period */
     42  RATE_MONOTONIC_INACTIVE,               /* off chain, never initialized */
     43  RATE_MONOTONIC_OWNER_IS_BLOCKING,      /* on chain, owner is blocking on it */
     44  RATE_MONOTONIC_ACTIVE,                 /* on chain, running continuously */
     45  RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, /* on chain, expired while owner was */
     46                                         /*   was blocking on it */
     47  RATE_MONOTONIC_EXPIRED                 /* off chain, will be reset by next */
     48                                         /*   rtems_rate_monotonic_period */
    4549}   Rate_Monotonic_Period_states;
    4650
     
    194198
    195199/*
    196  *  _Rate_monotonic_Set_state
    197  *
    198  *  DESCRIPTION:
    199  *
    200  *  This function blocks the calling task so that it is waiting for
    201  *  a period to expire.  It returns TRUE if the task was successfully
    202  *  blocked, and FALSE otherwise.
    203  */
    204 
    205 boolean _Rate_monotonic_Set_state(
    206   Rate_monotonic_Control *the_period
    207 );
    208 
    209 /*
    210200 *  _Rate_monotonic_Timeout
    211201 *
  • c/src/exec/rtems/src/ratemon.c

    r8d0b7d96 r11ab74e  
    234234)
    235235{
    236   Rate_monotonic_Control *the_period;
    237   Objects_Locations       location;
    238   rtems_status_code       return_value;
     236  Rate_monotonic_Control        *the_period;
     237  Objects_Locations              location;
     238  rtems_status_code              return_value;
     239  Rate_Monotonic_Period_states   local_state;
     240  ISR_Level                      level;
    239241
    240242  the_period = _Rate_monotonic_Get( id, &location );
     
    269271      }
    270272
     273      _ISR_Disable( level );
    271274      switch ( the_period->state ) {
    272275        case RATE_MONOTONIC_INACTIVE:
     276          _ISR_Enable( level );
    273277          the_period->state = RATE_MONOTONIC_ACTIVE;
    274278          _Watchdog_Initialize(
     
    283287
    284288        case RATE_MONOTONIC_ACTIVE:
    285 /* following is and could be a critical section problem */
    286           _Thread_Executing->Wait.id  = the_period->Object.id;
    287           if ( _Rate_monotonic_Set_state( the_period ) ) {
    288             _Thread_Enable_dispatch();
    289             return RTEMS_SUCCESSFUL;
    290           }
    291          /* has expired -- fall into next case */
     289          /*
     290           *  This tells the _Rate_monotonic_Timeout that this task is
     291           *  in the process of blocking on the period.
     292           */
     293
     294          the_period->state = RATE_MONOTONIC_OWNER_IS_BLOCKING;
     295          _ISR_Enable( level );
     296
     297          _Thread_Executing->Wait.id = the_period->Object.id;
     298          _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
     299         
     300          /*
     301           *  Did the watchdog timer expire while we were actually blocking
     302           *  on it?
     303           */
     304
     305          _ISR_Disable( level );
     306            local_state = the_period->state;
     307            the_period->state = RATE_MONOTONIC_ACTIVE;
     308          _ISR_Enable( level );
     309
     310          /*
     311           *  If it did, then we want to unblock ourself and continue as
     312           *  if nothing happen.  The period was reset in the timeout routine.
     313           */
     314
     315          if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING )
     316            _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
     317
     318          _Thread_Enable_dispatch();
     319          return RTEMS_SUCCESSFUL;
     320          break;
     321
    292322        case RATE_MONOTONIC_EXPIRED:
     323          _ISR_Enable( level );
    293324          the_period->state = RATE_MONOTONIC_ACTIVE;
    294325          _Watchdog_Insert_ticks( &the_period->Timer, length );
    295326          _Thread_Enable_dispatch();
    296327          return RTEMS_TIMEOUT;
     328
     329        case RATE_MONOTONIC_OWNER_IS_BLOCKING:
     330        case RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING:
     331          /*
     332           *  These should never happen.
     333           */
     334          break;
    297335      }
    298336  }
    299337
    300338  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    301 }
    302 
    303 /*PAGE
    304  *
    305  * _Rate_monotonic_Set_state
    306  *
    307  * This kernel routine sets the STATES_WAITING_FOR_PERIOD state in
    308  * the running thread's tcb if the specified period has not expired.
    309  * The ready chain is adjusted if necessary.
    310  *
    311  * Input parameters:
    312  *   the_period - pointer to period control block
    313  *
    314  * Output parameters:
    315  *   TRUE  - if blocked successfully for period
    316  *   FALSE - if period has expired
    317  *
    318  *  INTERRUPT LATENCY:
    319  *    delete node
    320  *    priority map
    321  *    select heir
    322  */
    323 
    324 boolean _Rate_monotonic_Set_state(
    325 Rate_monotonic_Control *the_period
    326 )
    327 {
    328   Thread_Control *executing;
    329   Chain_Control  *ready;
    330   ISR_Level              level;
    331   States_Control         old_state;
    332 
    333   executing = _Thread_Executing;
    334   ready     = executing->ready;
    335   _ISR_Disable( level );
    336 
    337   old_state = executing->current_state;
    338 
    339   if ( _Rate_monotonic_Is_expired( the_period ) ) {
    340     _ISR_Enable( level );
    341     return( FALSE );
    342   }
    343 
    344   executing->current_state =
    345              _States_Set( STATES_WAITING_FOR_PERIOD, old_state );
    346 
    347   if ( _States_Is_ready( old_state ) ) {
    348     if ( _Chain_Has_only_one_node( ready ) ) {
    349       _Chain_Initialize_empty( ready );
    350       _Priority_Remove_from_bit_map( &executing->Priority_map );
    351       _ISR_Flash( level );
    352     } else {
    353       _Chain_Extract_unprotected( &executing->Object.Node );
    354       _ISR_Flash( level );
    355     }
    356 
    357     if ( _Thread_Is_heir( executing ) )
    358       _Thread_Calculate_heir();
    359 
    360     _Context_Switch_necessary = TRUE;
    361   }
    362 
    363   _ISR_Enable( level );
    364   return( TRUE );
    365339}
    366340
     
    386360{
    387361  Rate_monotonic_Control *the_period;
    388   Objects_Locations              location;
     362  Objects_Locations       location;
    389363  Thread_Control         *the_thread;
    390364
     
    400374        _Thread_Unblock( the_thread );
    401375        _Watchdog_Reset( &the_period->Timer );
    402       }
    403       else
     376      } else if ( the_period->state == RATE_MONOTONIC_OWNER_IS_BLOCKING ) {
     377        the_period->state = RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING;
     378        _Watchdog_Reset( &the_period->Timer );
     379      } else
    404380        the_period->state = RATE_MONOTONIC_EXPIRED;
    405381      _Thread_Unnest_dispatch();
  • cpukit/rtems/include/rtems/rtems/ratemon.h

    r8d0b7d96 r11ab74e  
    4040
    4141typedef enum {
    42   RATE_MONOTONIC_INACTIVE,  /* off chain, never initialized */
    43   RATE_MONOTONIC_ACTIVE,    /* on chain, running continuously */
    44   RATE_MONOTONIC_EXPIRED    /* off chain, will be reset by next rm_period */
     42  RATE_MONOTONIC_INACTIVE,               /* off chain, never initialized */
     43  RATE_MONOTONIC_OWNER_IS_BLOCKING,      /* on chain, owner is blocking on it */
     44  RATE_MONOTONIC_ACTIVE,                 /* on chain, running continuously */
     45  RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING, /* on chain, expired while owner was */
     46                                         /*   was blocking on it */
     47  RATE_MONOTONIC_EXPIRED                 /* off chain, will be reset by next */
     48                                         /*   rtems_rate_monotonic_period */
    4549}   Rate_Monotonic_Period_states;
    4650
     
    194198
    195199/*
    196  *  _Rate_monotonic_Set_state
    197  *
    198  *  DESCRIPTION:
    199  *
    200  *  This function blocks the calling task so that it is waiting for
    201  *  a period to expire.  It returns TRUE if the task was successfully
    202  *  blocked, and FALSE otherwise.
    203  */
    204 
    205 boolean _Rate_monotonic_Set_state(
    206   Rate_monotonic_Control *the_period
    207 );
    208 
    209 /*
    210200 *  _Rate_monotonic_Timeout
    211201 *
  • cpukit/rtems/src/ratemon.c

    r8d0b7d96 r11ab74e  
    234234)
    235235{
    236   Rate_monotonic_Control *the_period;
    237   Objects_Locations       location;
    238   rtems_status_code       return_value;
     236  Rate_monotonic_Control        *the_period;
     237  Objects_Locations              location;
     238  rtems_status_code              return_value;
     239  Rate_Monotonic_Period_states   local_state;
     240  ISR_Level                      level;
    239241
    240242  the_period = _Rate_monotonic_Get( id, &location );
     
    269271      }
    270272
     273      _ISR_Disable( level );
    271274      switch ( the_period->state ) {
    272275        case RATE_MONOTONIC_INACTIVE:
     276          _ISR_Enable( level );
    273277          the_period->state = RATE_MONOTONIC_ACTIVE;
    274278          _Watchdog_Initialize(
     
    283287
    284288        case RATE_MONOTONIC_ACTIVE:
    285 /* following is and could be a critical section problem */
    286           _Thread_Executing->Wait.id  = the_period->Object.id;
    287           if ( _Rate_monotonic_Set_state( the_period ) ) {
    288             _Thread_Enable_dispatch();
    289             return RTEMS_SUCCESSFUL;
    290           }
    291          /* has expired -- fall into next case */
     289          /*
     290           *  This tells the _Rate_monotonic_Timeout that this task is
     291           *  in the process of blocking on the period.
     292           */
     293
     294          the_period->state = RATE_MONOTONIC_OWNER_IS_BLOCKING;
     295          _ISR_Enable( level );
     296
     297          _Thread_Executing->Wait.id = the_period->Object.id;
     298          _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
     299         
     300          /*
     301           *  Did the watchdog timer expire while we were actually blocking
     302           *  on it?
     303           */
     304
     305          _ISR_Disable( level );
     306            local_state = the_period->state;
     307            the_period->state = RATE_MONOTONIC_ACTIVE;
     308          _ISR_Enable( level );
     309
     310          /*
     311           *  If it did, then we want to unblock ourself and continue as
     312           *  if nothing happen.  The period was reset in the timeout routine.
     313           */
     314
     315          if ( local_state == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING )
     316            _Thread_Clear_state( _Thread_Executing, STATES_WAITING_FOR_PERIOD );
     317
     318          _Thread_Enable_dispatch();
     319          return RTEMS_SUCCESSFUL;
     320          break;
     321
    292322        case RATE_MONOTONIC_EXPIRED:
     323          _ISR_Enable( level );
    293324          the_period->state = RATE_MONOTONIC_ACTIVE;
    294325          _Watchdog_Insert_ticks( &the_period->Timer, length );
    295326          _Thread_Enable_dispatch();
    296327          return RTEMS_TIMEOUT;
     328
     329        case RATE_MONOTONIC_OWNER_IS_BLOCKING:
     330        case RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING:
     331          /*
     332           *  These should never happen.
     333           */
     334          break;
    297335      }
    298336  }
    299337
    300338  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
    301 }
    302 
    303 /*PAGE
    304  *
    305  * _Rate_monotonic_Set_state
    306  *
    307  * This kernel routine sets the STATES_WAITING_FOR_PERIOD state in
    308  * the running thread's tcb if the specified period has not expired.
    309  * The ready chain is adjusted if necessary.
    310  *
    311  * Input parameters:
    312  *   the_period - pointer to period control block
    313  *
    314  * Output parameters:
    315  *   TRUE  - if blocked successfully for period
    316  *   FALSE - if period has expired
    317  *
    318  *  INTERRUPT LATENCY:
    319  *    delete node
    320  *    priority map
    321  *    select heir
    322  */
    323 
    324 boolean _Rate_monotonic_Set_state(
    325 Rate_monotonic_Control *the_period
    326 )
    327 {
    328   Thread_Control *executing;
    329   Chain_Control  *ready;
    330   ISR_Level              level;
    331   States_Control         old_state;
    332 
    333   executing = _Thread_Executing;
    334   ready     = executing->ready;
    335   _ISR_Disable( level );
    336 
    337   old_state = executing->current_state;
    338 
    339   if ( _Rate_monotonic_Is_expired( the_period ) ) {
    340     _ISR_Enable( level );
    341     return( FALSE );
    342   }
    343 
    344   executing->current_state =
    345              _States_Set( STATES_WAITING_FOR_PERIOD, old_state );
    346 
    347   if ( _States_Is_ready( old_state ) ) {
    348     if ( _Chain_Has_only_one_node( ready ) ) {
    349       _Chain_Initialize_empty( ready );
    350       _Priority_Remove_from_bit_map( &executing->Priority_map );
    351       _ISR_Flash( level );
    352     } else {
    353       _Chain_Extract_unprotected( &executing->Object.Node );
    354       _ISR_Flash( level );
    355     }
    356 
    357     if ( _Thread_Is_heir( executing ) )
    358       _Thread_Calculate_heir();
    359 
    360     _Context_Switch_necessary = TRUE;
    361   }
    362 
    363   _ISR_Enable( level );
    364   return( TRUE );
    365339}
    366340
     
    386360{
    387361  Rate_monotonic_Control *the_period;
    388   Objects_Locations              location;
     362  Objects_Locations       location;
    389363  Thread_Control         *the_thread;
    390364
     
    400374        _Thread_Unblock( the_thread );
    401375        _Watchdog_Reset( &the_period->Timer );
    402       }
    403       else
     376      } else if ( the_period->state == RATE_MONOTONIC_OWNER_IS_BLOCKING ) {
     377        the_period->state = RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING;
     378        _Watchdog_Reset( &the_period->Timer );
     379      } else
    404380        the_period->state = RATE_MONOTONIC_EXPIRED;
    405381      _Thread_Unnest_dispatch();
Note: See TracChangeset for help on using the changeset viewer.