Changeset 11ab74e in rtems
- Timestamp:
- 12/05/95 15:27:51 (27 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- ca201c9
- Parents:
- 8d0b7d96
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/rtems/headers/ratemon.h
r8d0b7d96 r11ab74e 40 40 41 41 typedef 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 */ 45 49 } Rate_Monotonic_Period_states; 46 50 … … 194 198 195 199 /* 196 * _Rate_monotonic_Set_state197 *198 * DESCRIPTION:199 *200 * This function blocks the calling task so that it is waiting for201 * a period to expire. It returns TRUE if the task was successfully202 * blocked, and FALSE otherwise.203 */204 205 boolean _Rate_monotonic_Set_state(206 Rate_monotonic_Control *the_period207 );208 209 /*210 200 * _Rate_monotonic_Timeout 211 201 * -
c/src/exec/rtems/include/rtems/rtems/ratemon.h
r8d0b7d96 r11ab74e 40 40 41 41 typedef 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 */ 45 49 } Rate_Monotonic_Period_states; 46 50 … … 194 198 195 199 /* 196 * _Rate_monotonic_Set_state197 *198 * DESCRIPTION:199 *200 * This function blocks the calling task so that it is waiting for201 * a period to expire. It returns TRUE if the task was successfully202 * blocked, and FALSE otherwise.203 */204 205 boolean _Rate_monotonic_Set_state(206 Rate_monotonic_Control *the_period207 );208 209 /*210 200 * _Rate_monotonic_Timeout 211 201 * -
c/src/exec/rtems/src/ratemon.c
r8d0b7d96 r11ab74e 234 234 ) 235 235 { 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; 239 241 240 242 the_period = _Rate_monotonic_Get( id, &location ); … … 269 271 } 270 272 273 _ISR_Disable( level ); 271 274 switch ( the_period->state ) { 272 275 case RATE_MONOTONIC_INACTIVE: 276 _ISR_Enable( level ); 273 277 the_period->state = RATE_MONOTONIC_ACTIVE; 274 278 _Watchdog_Initialize( … … 283 287 284 288 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 292 322 case RATE_MONOTONIC_EXPIRED: 323 _ISR_Enable( level ); 293 324 the_period->state = RATE_MONOTONIC_ACTIVE; 294 325 _Watchdog_Insert_ticks( &the_period->Timer, length ); 295 326 _Thread_Enable_dispatch(); 296 327 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; 297 335 } 298 336 } 299 337 300 338 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 301 }302 303 /*PAGE304 *305 * _Rate_monotonic_Set_state306 *307 * This kernel routine sets the STATES_WAITING_FOR_PERIOD state in308 * 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 block313 *314 * Output parameters:315 * TRUE - if blocked successfully for period316 * FALSE - if period has expired317 *318 * INTERRUPT LATENCY:319 * delete node320 * priority map321 * select heir322 */323 324 boolean _Rate_monotonic_Set_state(325 Rate_monotonic_Control *the_period326 )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 );365 339 } 366 340 … … 386 360 { 387 361 Rate_monotonic_Control *the_period; 388 Objects_Locations 362 Objects_Locations location; 389 363 Thread_Control *the_thread; 390 364 … … 400 374 _Thread_Unblock( the_thread ); 401 375 _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 404 380 the_period->state = RATE_MONOTONIC_EXPIRED; 405 381 _Thread_Unnest_dispatch(); -
cpukit/rtems/include/rtems/rtems/ratemon.h
r8d0b7d96 r11ab74e 40 40 41 41 typedef 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 */ 45 49 } Rate_Monotonic_Period_states; 46 50 … … 194 198 195 199 /* 196 * _Rate_monotonic_Set_state197 *198 * DESCRIPTION:199 *200 * This function blocks the calling task so that it is waiting for201 * a period to expire. It returns TRUE if the task was successfully202 * blocked, and FALSE otherwise.203 */204 205 boolean _Rate_monotonic_Set_state(206 Rate_monotonic_Control *the_period207 );208 209 /*210 200 * _Rate_monotonic_Timeout 211 201 * -
cpukit/rtems/src/ratemon.c
r8d0b7d96 r11ab74e 234 234 ) 235 235 { 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; 239 241 240 242 the_period = _Rate_monotonic_Get( id, &location ); … … 269 271 } 270 272 273 _ISR_Disable( level ); 271 274 switch ( the_period->state ) { 272 275 case RATE_MONOTONIC_INACTIVE: 276 _ISR_Enable( level ); 273 277 the_period->state = RATE_MONOTONIC_ACTIVE; 274 278 _Watchdog_Initialize( … … 283 287 284 288 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 292 322 case RATE_MONOTONIC_EXPIRED: 323 _ISR_Enable( level ); 293 324 the_period->state = RATE_MONOTONIC_ACTIVE; 294 325 _Watchdog_Insert_ticks( &the_period->Timer, length ); 295 326 _Thread_Enable_dispatch(); 296 327 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; 297 335 } 298 336 } 299 337 300 338 return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ 301 }302 303 /*PAGE304 *305 * _Rate_monotonic_Set_state306 *307 * This kernel routine sets the STATES_WAITING_FOR_PERIOD state in308 * 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 block313 *314 * Output parameters:315 * TRUE - if blocked successfully for period316 * FALSE - if period has expired317 *318 * INTERRUPT LATENCY:319 * delete node320 * priority map321 * select heir322 */323 324 boolean _Rate_monotonic_Set_state(325 Rate_monotonic_Control *the_period326 )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 );365 339 } 366 340 … … 386 360 { 387 361 Rate_monotonic_Control *the_period; 388 Objects_Locations 362 Objects_Locations location; 389 363 Thread_Control *the_thread; 390 364 … … 400 374 _Thread_Unblock( the_thread ); 401 375 _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 404 380 the_period->state = RATE_MONOTONIC_EXPIRED; 405 381 _Thread_Unnest_dispatch();
Note: See TracChangeset
for help on using the changeset viewer.