Ignore:
Timestamp:
Aug 30, 2001, 6:32:12 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
b68cc333
Parents:
ca739de3
Message:

2001-08-30 Joel Sherrill <joel@…>

  • src/coremutex.c, src/coremutexseize.c, src/coremutexsurrender.c: The per thread field resource_count should only be manipulated when a mutex is priority ceiling or priority inherit. This was reported by Chris Johns <ccj@…> who also noticed that the use of switches for all disciplines generated less efficient code than using explicit tests for the one or two cases we were really interested in. Further review of his modifications made it apparent that the "isa" methods to test mutex discipline were not being used so this modification was swept into the code as well.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/src/coremutexseize.c

    rca739de3 r6f1118a  
    5454
    5555  executing = _Thread_Executing;
    56   switch ( the_mutex->Attributes.discipline ) {
    57     case CORE_MUTEX_DISCIPLINES_FIFO:
    58     case CORE_MUTEX_DISCIPLINES_PRIORITY:
    59     case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    60       break;
    61     case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    62       if ( executing->current_priority <
    63                               the_mutex->Attributes.priority_ceiling) {
    64         executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED;
    65         return;
    66       }
     56  if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
     57    if ( executing->current_priority < the_mutex->Attributes.priority_ceiling) {
     58      executing->Wait.return_code = CORE_MUTEX_STATUS_CEILING_VIOLATED;
     59      return;
     60    }
    6761  }
    6862  executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
     
    7367    the_mutex->holder_id  = executing->Object.id;
    7468    the_mutex->nest_count = 1;
    75     executing->resource_count++;
     69    if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ||
     70         _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) )
     71      executing->resource_count++;
    7672    _ISR_Enable( level );
    77     switch ( the_mutex->Attributes.discipline ) {
    78       case CORE_MUTEX_DISCIPLINES_FIFO:
    79       case CORE_MUTEX_DISCIPLINES_PRIORITY:
    80       case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    81         /* already the highest priority */
    82         break;
    83       case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    84       if ( the_mutex->Attributes.priority_ceiling <
    85                                            executing->current_priority ) {
     73    /*
     74     *  if CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT then nothing to do
     75     *  because this task is already the highest priority.
     76     */
     77
     78    if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
     79      if (the_mutex->Attributes.priority_ceiling < executing->current_priority){
    8680        _Thread_Change_priority(
    8781          the_mutex->holder,
     
    121115  _ISR_Enable( level );
    122116
    123   switch ( the_mutex->Attributes.discipline ) {
    124     case CORE_MUTEX_DISCIPLINES_FIFO:
    125     case CORE_MUTEX_DISCIPLINES_PRIORITY:
    126     case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    127       break;
    128     case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    129       if ( the_mutex->holder->current_priority > executing->current_priority ) {
    130         _Thread_Change_priority(
    131           the_mutex->holder,
    132           executing->current_priority,
    133           FALSE
    134         );
    135       }
    136       break;
     117  if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
     118    if ( the_mutex->holder->current_priority > executing->current_priority ) {
     119      _Thread_Change_priority(
     120        the_mutex->holder,
     121        executing->current_priority,
     122        FALSE
     123      );
     124    }
    137125  }
    138126
     
    140128
    141129  if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) {
    142     switch ( the_mutex->Attributes.discipline ) {
    143       case CORE_MUTEX_DISCIPLINES_FIFO:
    144       case CORE_MUTEX_DISCIPLINES_PRIORITY:
    145       case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT:
    146         break;
    147       case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING:
    148         if ( the_mutex->Attributes.priority_ceiling <
    149                                            executing->current_priority ) {
    150           _Thread_Change_priority(
    151             executing,
    152             the_mutex->Attributes.priority_ceiling,
    153             FALSE
    154           );
    155         };
    156         break;
     130    if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
     131      if (the_mutex->Attributes.priority_ceiling < executing->current_priority){
     132        _Thread_Change_priority(
     133          executing,
     134          the_mutex->Attributes.priority_ceiling,
     135          FALSE
     136        );
     137      }
    157138    }
    158139  }
Note: See TracChangeset for help on using the changeset viewer.