Changeset fb1d8f81 in rtems
- Timestamp:
- 08/30/01 18:33:57 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 7078fa2a
- Parents:
- 760045f0
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/score/ChangeLog
r760045f0 rfb1d8f81 1 2 2001-08-30 Joel Sherrill <joel@OARcorp.com> 3 4 * src/coremutex.c, src/coremutexseize.c, src/coremutexsurrender.c, 5 inline/rtems/score/coremutex.inl: The per thread field resource_count 6 should only be manipulated when a mutex is priority ceiling or 7 priority inherit. This was reported by Chris Johns <ccj@acm.org> 8 who also noticed that the use of switches for all disciplines 9 generated less efficient code than using explicit tests for the one 10 or two cases we were really interested in. Further review of his 11 modifications made it apparent that the "isa" methods to test mutex 12 discipline were not being used so this modification was swept into 13 the code as well. 1 14 2 15 2001-08-30 Joel Sherrill <joel@OARcorp.com> -
c/src/exec/score/inline/rtems/score/coremutex.inl
r760045f0 rfb1d8f81 135 135 the_mutex->holder_id = executing->Object.id; 136 136 the_mutex->nest_count = 1; 137 executing->resource_count++; 138 if ( the_mutex->Attributes.discipline != 139 CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) { 137 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 138 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 139 executing->resource_count++; 140 if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 140 141 _ISR_Enable( level ); 141 142 return 0; -
c/src/exec/score/src/coremutex.c
r760045f0 rfb1d8f81 74 74 the_mutex->holder = _Thread_Executing; 75 75 the_mutex->holder_id = _Thread_Executing->Object.id; 76 _Thread_Executing->resource_count++; 76 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 77 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 78 _Thread_Executing->resource_count++; 77 79 } else { 78 80 the_mutex->nest_count = 0; -
c/src/exec/score/src/coremutexseize.c
r760045f0 rfb1d8f81 44 44 45 45 executing = _Thread_Executing; 46 switch ( the_mutex->Attributes.discipline ) { 47 case CORE_MUTEX_DISCIPLINES_FIFO: 48 case CORE_MUTEX_DISCIPLINES_PRIORITY: 49 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 50 break; 51 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 52 if ( the_mutex->holder->current_priority > executing->current_priority ) { 53 _Thread_Change_priority( 54 the_mutex->holder, 55 executing->current_priority, 56 FALSE 57 ); 58 } 59 break; 46 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { 47 if ( the_mutex->holder->current_priority > executing->current_priority ) { 48 _Thread_Change_priority( 49 the_mutex->holder, 50 executing->current_priority, 51 FALSE 52 ); 53 } 60 54 } 61 55 … … 64 58 65 59 if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) { 66 switch ( the_mutex->Attributes.discipline ) { 67 case CORE_MUTEX_DISCIPLINES_FIFO: 68 case CORE_MUTEX_DISCIPLINES_PRIORITY: 69 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 70 break; 71 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 72 if ( the_mutex->Attributes.priority_ceiling < 73 executing->current_priority ) { 74 _Thread_Change_priority( 75 executing, 76 the_mutex->Attributes.priority_ceiling, 77 FALSE 78 ); 79 }; 80 break; 60 /* 61 * if CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT then nothing to do 62 * because this task is already the highest priority. 63 */ 64 65 if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 66 if (the_mutex->Attributes.priority_ceiling < executing->current_priority){ 67 _Thread_Change_priority( 68 executing, 69 the_mutex->Attributes.priority_ceiling, 70 FALSE 71 ); 72 } 81 73 } 82 74 } … … 102 94 the_mutex->holder_id = executing->Object.id; 103 95 the_mutex->nest_count = 1; 104 executing->resource_count++; 105 if ( the_mutex->Attributes.discipline != 106 CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) { 107 _ISR_Enable( level ); 108 return 0; 96 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 97 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 98 executing->resource_count++; 99 100 if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 101 _ISR_Enable( level ); 102 return 0; 109 103 } 110 104 /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING */ … … 140 134 return 0; 141 135 } 136 137 if ( _Thread_Is_executing( the_mutex->holder ) ) { 138 switch ( the_mutex->Attributes.lock_nesting_behavior ) { 139 case CORE_MUTEX_NESTING_ACQUIRES: 140 the_mutex->nest_count++; 141 _ISR_Enable( level ); 142 return 0; 143 case CORE_MUTEX_NESTING_IS_ERROR: 144 executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; 145 _ISR_Enable( level ); 146 return 0; 147 case CORE_MUTEX_NESTING_BLOCKS: 148 break; 149 } 150 } 151 142 152 return 1; 143 153 } -
c/src/exec/score/src/coremutexsurrender.c
r760045f0 rfb1d8f81 87 87 } 88 88 89 holder->resource_count--; 89 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 90 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 91 holder->resource_count--; 90 92 the_mutex->holder = NULL; 91 93 the_mutex->holder_id = 0; … … 97 99 */ 98 100 99 switch ( the_mutex->Attributes.discipline ) { 100 case CORE_MUTEX_DISCIPLINES_FIFO: 101 case CORE_MUTEX_DISCIPLINES_PRIORITY: 102 break; 103 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 104 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 105 if ( holder->resource_count == 0 && 106 holder->real_priority != holder->current_priority ) { 107 _Thread_Change_priority( holder, holder->real_priority, TRUE ); 108 } 109 break; 101 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 102 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 103 if ( holder->resource_count == 0 && 104 holder->real_priority != holder->current_priority ) { 105 _Thread_Change_priority( holder, holder->real_priority, TRUE ); 106 } 110 107 } 111 112 108 113 109 if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) { … … 128 124 the_mutex->holder = the_thread; 129 125 the_mutex->holder_id = the_thread->Object.id; 130 the_thread->resource_count++; 126 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 127 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 128 the_thread->resource_count++; 131 129 the_mutex->nest_count = 1; 132 130 -
cpukit/score/ChangeLog
r760045f0 rfb1d8f81 1 2 2001-08-30 Joel Sherrill <joel@OARcorp.com> 3 4 * src/coremutex.c, src/coremutexseize.c, src/coremutexsurrender.c, 5 inline/rtems/score/coremutex.inl: The per thread field resource_count 6 should only be manipulated when a mutex is priority ceiling or 7 priority inherit. This was reported by Chris Johns <ccj@acm.org> 8 who also noticed that the use of switches for all disciplines 9 generated less efficient code than using explicit tests for the one 10 or two cases we were really interested in. Further review of his 11 modifications made it apparent that the "isa" methods to test mutex 12 discipline were not being used so this modification was swept into 13 the code as well. 1 14 2 15 2001-08-30 Joel Sherrill <joel@OARcorp.com> -
cpukit/score/inline/rtems/score/coremutex.inl
r760045f0 rfb1d8f81 135 135 the_mutex->holder_id = executing->Object.id; 136 136 the_mutex->nest_count = 1; 137 executing->resource_count++; 138 if ( the_mutex->Attributes.discipline != 139 CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) { 137 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 138 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 139 executing->resource_count++; 140 if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 140 141 _ISR_Enable( level ); 141 142 return 0; -
cpukit/score/src/coremutex.c
r760045f0 rfb1d8f81 74 74 the_mutex->holder = _Thread_Executing; 75 75 the_mutex->holder_id = _Thread_Executing->Object.id; 76 _Thread_Executing->resource_count++; 76 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 77 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 78 _Thread_Executing->resource_count++; 77 79 } else { 78 80 the_mutex->nest_count = 0; -
cpukit/score/src/coremutexseize.c
r760045f0 rfb1d8f81 44 44 45 45 executing = _Thread_Executing; 46 switch ( the_mutex->Attributes.discipline ) { 47 case CORE_MUTEX_DISCIPLINES_FIFO: 48 case CORE_MUTEX_DISCIPLINES_PRIORITY: 49 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 50 break; 51 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 52 if ( the_mutex->holder->current_priority > executing->current_priority ) { 53 _Thread_Change_priority( 54 the_mutex->holder, 55 executing->current_priority, 56 FALSE 57 ); 58 } 59 break; 46 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { 47 if ( the_mutex->holder->current_priority > executing->current_priority ) { 48 _Thread_Change_priority( 49 the_mutex->holder, 50 executing->current_priority, 51 FALSE 52 ); 53 } 60 54 } 61 55 … … 64 58 65 59 if ( _Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL ) { 66 switch ( the_mutex->Attributes.discipline ) { 67 case CORE_MUTEX_DISCIPLINES_FIFO: 68 case CORE_MUTEX_DISCIPLINES_PRIORITY: 69 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 70 break; 71 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 72 if ( the_mutex->Attributes.priority_ceiling < 73 executing->current_priority ) { 74 _Thread_Change_priority( 75 executing, 76 the_mutex->Attributes.priority_ceiling, 77 FALSE 78 ); 79 }; 80 break; 60 /* 61 * if CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT then nothing to do 62 * because this task is already the highest priority. 63 */ 64 65 if ( _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 66 if (the_mutex->Attributes.priority_ceiling < executing->current_priority){ 67 _Thread_Change_priority( 68 executing, 69 the_mutex->Attributes.priority_ceiling, 70 FALSE 71 ); 72 } 81 73 } 82 74 } … … 102 94 the_mutex->holder_id = executing->Object.id; 103 95 the_mutex->nest_count = 1; 104 executing->resource_count++; 105 if ( the_mutex->Attributes.discipline != 106 CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) { 107 _ISR_Enable( level ); 108 return 0; 96 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 97 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 98 executing->resource_count++; 99 100 if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 101 _ISR_Enable( level ); 102 return 0; 109 103 } 110 104 /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING */ … … 140 134 return 0; 141 135 } 136 137 if ( _Thread_Is_executing( the_mutex->holder ) ) { 138 switch ( the_mutex->Attributes.lock_nesting_behavior ) { 139 case CORE_MUTEX_NESTING_ACQUIRES: 140 the_mutex->nest_count++; 141 _ISR_Enable( level ); 142 return 0; 143 case CORE_MUTEX_NESTING_IS_ERROR: 144 executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; 145 _ISR_Enable( level ); 146 return 0; 147 case CORE_MUTEX_NESTING_BLOCKS: 148 break; 149 } 150 } 151 142 152 return 1; 143 153 } -
cpukit/score/src/coremutexsurrender.c
r760045f0 rfb1d8f81 87 87 } 88 88 89 holder->resource_count--; 89 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 90 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 91 holder->resource_count--; 90 92 the_mutex->holder = NULL; 91 93 the_mutex->holder_id = 0; … … 97 99 */ 98 100 99 switch ( the_mutex->Attributes.discipline ) { 100 case CORE_MUTEX_DISCIPLINES_FIFO: 101 case CORE_MUTEX_DISCIPLINES_PRIORITY: 102 break; 103 case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: 104 case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: 105 if ( holder->resource_count == 0 && 106 holder->real_priority != holder->current_priority ) { 107 _Thread_Change_priority( holder, holder->real_priority, TRUE ); 108 } 109 break; 101 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 102 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { 103 if ( holder->resource_count == 0 && 104 holder->real_priority != holder->current_priority ) { 105 _Thread_Change_priority( holder, holder->real_priority, TRUE ); 106 } 110 107 } 111 112 108 113 109 if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) { … … 128 124 the_mutex->holder = the_thread; 129 125 the_mutex->holder_id = the_thread->Object.id; 130 the_thread->resource_count++; 126 if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || 127 _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) 128 the_thread->resource_count++; 131 129 the_mutex->nest_count = 1; 132 130
Note: See TracChangeset
for help on using the changeset viewer.