Changeset 53ad908 in rtems
- Timestamp:
- Mar 7, 2014, 1:36:22 PM (6 years ago)
- Branches:
- 4.11, master
- Children:
- de5d6d0
- Parents:
- f980561
- git-author:
- Sebastian Huber <sebastian.huber@…> (03/07/14 13:36:22)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (03/14/14 07:46:49)
- Files:
-
- 1 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/sparc/leon3/amba/amba.c
rf980561 r53ad908 24 24 struct ambapp_bus ambapp_plb; 25 25 26 rtems_interrupt_lock LEON3_IrqCtrl_Lock = RTEMS_INTERRUPT_LOCK_INITIALIZER; 26 rtems_interrupt_lock LEON3_IrqCtrl_Lock = 27 RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl"); 27 28 28 29 /* Pointers to Interrupt Controller configuration registers */ -
cpukit/libblock/src/diskdevs.c
rf980561 r53ad908 58 58 static volatile bool diskdevs_protected; 59 59 60 static rtems_interrupt_lock diskdevs_lock = RTEMS_INTERRUPT_LOCK_INITIALIZER; 60 static rtems_interrupt_lock diskdevs_lock = 61 RTEMS_INTERRUPT_LOCK_INITIALIZER("diskdevs"); 61 62 62 63 static rtems_status_code -
cpukit/libcsupport/src/sup_fs_location.c
rf980561 r53ad908 30 30 31 31 rtems_interrupt_lock rtems_filesystem_mt_entry_lock_control = 32 RTEMS_INTERRUPT_LOCK_INITIALIZER ;32 RTEMS_INTERRUPT_LOCK_INITIALIZER("mount table entry"); 33 33 34 34 static rtems_filesystem_global_location_t *deferred_released_global_locations; -
cpukit/libcsupport/src/termios.c
rf980561 r53ad908 231 231 tty->device = *callbacks; 232 232 233 rtems_interrupt_lock_initialize (&tty->interrupt_lock );233 rtems_interrupt_lock_initialize (&tty->interrupt_lock, "Termios"); 234 234 235 235 /* -
cpukit/posix/src/psignal.c
rf980561 r53ad908 46 46 /*** PROCESS WIDE STUFF ****/ 47 47 48 ISR_lock_Control _POSIX_signals_Lock = ISR_LOCK_INITIALIZER ;48 ISR_lock_Control _POSIX_signals_Lock = ISR_LOCK_INITIALIZER("POSIX signals"); 49 49 50 50 sigset_t _POSIX_signals_Pending; -
cpukit/rtems/include/rtems/rtems/asrimpl.h
rf980561 r53ad908 47 47 asr->signals_pending = 0; 48 48 asr->nest_level = 0; 49 _ISR_lock_Initialize( &asr->Lock );49 _ISR_lock_Initialize( &asr->Lock, "ASR" ); 50 50 } 51 51 -
cpukit/rtems/include/rtems/rtems/intr.h
rf980561 r53ad908 168 168 * @brief Initializer for static initialization of interrupt locks. 169 169 */ 170 #define RTEMS_INTERRUPT_LOCK_INITIALIZER ISR_LOCK_INITIALIZER170 #define RTEMS_INTERRUPT_LOCK_INITIALIZER( _name ) ISR_LOCK_INITIALIZER( _name ) 171 171 172 172 /** … … 176 176 * 177 177 * @param[in,out] _lock The interrupt lock. 178 */ 179 #define rtems_interrupt_lock_initialize( _lock ) \ 180 _ISR_lock_Initialize( _lock ) 178 * @param[in] _name The name for the interrupt lock. This name must be 179 * persistent throughout the life time of this lock. 180 */ 181 #define rtems_interrupt_lock_initialize( _lock, _name ) \ 182 _ISR_lock_Initialize( _lock, _name ) 181 183 182 184 /** -
cpukit/sapi/src/chainsmp.c
rf980561 r53ad908 23 23 #include <rtems/score/smplock.h> 24 24 25 static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER ;25 static SMP_lock_Control chain_lock = SMP_LOCK_INITIALIZER("chains"); 26 26 27 27 static void chain_acquire( SMP_lock_Context *lock_context ) -
cpukit/sapi/src/profilingiterate.c
rf980561 r53ad908 19 19 #include <rtems/profiling.h> 20 20 #include <rtems/counter.h> 21 #include <rtems/score/smplock.h> 21 22 #include <rtems.h> 22 23 … … 77 78 } 78 79 80 #if defined(RTEMS_PROFILING) && defined(RTEMS_SMP) 81 RTEMS_STATIC_ASSERT( 82 RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS 83 == SMP_LOCK_STATS_CONTENTION_COUNTS, 84 smp_lock_contention_counts 85 ); 86 #endif 87 88 static void smp_lock_stats_iterate( 89 rtems_profiling_visitor visitor, 90 void *visitor_arg, 91 rtems_profiling_data *data 92 ) 93 { 94 #if defined(RTEMS_PROFILING) && defined(RTEMS_SMP) 95 SMP_lock_Stats_iteration_context iteration_context; 96 SMP_lock_Stats snapshot; 97 char name[64]; 98 99 memset(data, 0, sizeof(*data)); 100 data->header.type = RTEMS_PROFILING_SMP_LOCK; 101 102 _SMP_lock_Stats_iteration_start(&iteration_context); 103 while ( 104 _SMP_lock_Stats_iteration_next( 105 &iteration_context, 106 &snapshot, 107 &name[0], 108 sizeof(name) 109 ) 110 ) { 111 rtems_profiling_smp_lock *smp_lock_data = &data->smp_lock; 112 113 smp_lock_data->name = name; 114 smp_lock_data->max_acquire_time = 115 rtems_counter_ticks_to_nanoseconds(snapshot.max_acquire_time); 116 smp_lock_data->max_section_time = 117 rtems_counter_ticks_to_nanoseconds(snapshot.max_section_time); 118 smp_lock_data->usage_count = snapshot.usage_count; 119 smp_lock_data->total_acquire_time = 120 rtems_counter_ticks_to_nanoseconds(snapshot.total_acquire_time); 121 smp_lock_data->total_section_time = 122 rtems_counter_ticks_to_nanoseconds(snapshot.total_section_time); 123 124 memcpy( 125 &smp_lock_data->contention_counts[0], 126 &snapshot.contention_counts[0], 127 sizeof(smp_lock_data->contention_counts) 128 ); 129 130 (*visitor)(visitor_arg, data); 131 } 132 _SMP_lock_Stats_iteration_stop(&iteration_context); 133 #else 134 (void) visitor; 135 (void) visitor_arg; 136 (void) data; 137 #endif 138 } 139 79 140 void rtems_profiling_iterate( 80 141 rtems_profiling_visitor visitor, … … 85 146 86 147 per_cpu_stats_iterate(visitor, visitor_arg, &data); 148 smp_lock_stats_iterate(visitor, visitor_arg, &data); 87 149 } -
cpukit/score/Makefile.am
rf980561 r53ad908 124 124 125 125 if HAS_SMP 126 libscore_a_SOURCES += src/profilingsmplock.c 126 127 libscore_a_SOURCES += src/schedulerprioritysmp.c 127 128 libscore_a_SOURCES += src/schedulersimplesmp.c -
cpukit/score/include/rtems/score/isrlock.h
rf980561 r53ad908 72 72 */ 73 73 #if defined( RTEMS_SMP ) 74 #define ISR_LOCK_INITIALIZER \75 { SMP_LOCK_INITIALIZER }76 #else 77 #define ISR_LOCK_INITIALIZER \74 #define ISR_LOCK_INITIALIZER( name ) \ 75 { SMP_LOCK_INITIALIZER( name ) } 76 #else 77 #define ISR_LOCK_INITIALIZER( name ) \ 78 78 { } 79 79 #endif … … 85 85 * 86 86 * @param[in,out] lock The ISR lock control. 87 */ 88 static inline void _ISR_lock_Initialize( ISR_lock_Control *lock ) 89 { 90 #if defined( RTEMS_SMP ) 91 _SMP_lock_Initialize( &lock->lock ); 92 #else 93 (void) lock; 87 * @param[in] name The name for the ISR lock. This name must be persistent 88 * throughout the life time of this lock. 89 */ 90 static inline void _ISR_lock_Initialize( 91 ISR_lock_Control *lock, 92 const char *name 93 ) 94 { 95 #if defined( RTEMS_SMP ) 96 _SMP_lock_Initialize( &lock->lock, name ); 97 #else 98 (void) lock; 99 (void) name; 94 100 #endif 95 101 } -
cpukit/score/include/rtems/score/percpu.h
rf980561 r53ad908 41 41 * processor. 42 42 */ 43 #define PER_CPU_CONTROL_SIZE_LOG2 7 43 #if defined( RTEMS_PROFILING ) 44 #define PER_CPU_CONTROL_SIZE_LOG2 8 45 #else 46 #define PER_CPU_CONTROL_SIZE_LOG2 7 47 #endif 44 48 45 49 #define PER_CPU_CONTROL_SIZE ( 1 << PER_CPU_CONTROL_SIZE_LOG2 ) … … 288 292 289 293 /** 294 * @brief Lock statistics context for the per-CPU lock. 295 */ 296 SMP_lock_Stats_context Lock_stats_context; 297 298 /** 290 299 * @brief Context for the Giant lock acquire and release pair of this 291 300 * processor. … … 334 343 #if defined( RTEMS_SMP ) 335 344 #define _Per_CPU_Acquire( per_cpu ) \ 336 _SMP_ticket_lock_Acquire( &( per_cpu )->Lock ) 345 _SMP_ticket_lock_Acquire( \ 346 &( per_cpu )->Lock, \ 347 &( per_cpu )->Lock_stats_context \ 348 ) 337 349 #else 338 350 #define _Per_CPU_Acquire( per_cpu ) \ … … 344 356 #if defined( RTEMS_SMP ) 345 357 #define _Per_CPU_Release( per_cpu ) \ 346 _SMP_ticket_lock_Release( &( per_cpu )->Lock ) 358 _SMP_ticket_lock_Release( \ 359 &( per_cpu )->Lock, \ 360 &( per_cpu )->Lock_stats_context \ 361 ) 347 362 #else 348 363 #define _Per_CPU_Release( per_cpu ) \ -
cpukit/score/include/rtems/score/smplock.h
rf980561 r53ad908 28 28 #include <rtems/score/isrlevel.h> 29 29 30 #if defined( RTEMS_PROFILING ) 31 #include <rtems/score/chainimpl.h> 32 #include <string.h> 33 #endif 34 30 35 #ifdef __cplusplus 31 36 extern "C" { … … 51 56 52 57 /** 58 * @brief Count of lock contention counters for lock statistics. 59 */ 60 #define SMP_LOCK_STATS_CONTENTION_COUNTS 4 61 62 /** 63 * @brief SMP lock statistics. 64 * 65 * The lock acquire attempt instant is the point in time right after the 66 * interrupt disable action in the lock acquire sequence. 67 * 68 * The lock acquire instant is the point in time right after the lock 69 * acquisition. This is the begin of the critical section code execution. 70 * 71 * The lock release instant is the point in time right before the interrupt 72 * enable action in the lock release sequence. 73 * 74 * The lock section time is the time elapsed between the lock acquire instant 75 * and the lock release instant. 76 * 77 * The lock acquire time is the time elapsed between the lock acquire attempt 78 * instant and the lock acquire instant. 79 */ 80 typedef struct { 81 #if defined( RTEMS_PROFILING ) 82 /** 83 * @brief Node for SMP lock statistics chain. 84 */ 85 Chain_Node Node; 86 87 /** 88 * @brief The maximum lock acquire time in CPU counter ticks. 89 */ 90 CPU_Counter_ticks max_acquire_time; 91 92 /** 93 * @brief The maximum lock section time in CPU counter ticks. 94 */ 95 CPU_Counter_ticks max_section_time; 96 97 /** 98 * @brief The count of lock uses. 99 * 100 * This value may overflow. 101 */ 102 uint64_t usage_count; 103 104 /** 105 * @brief Total lock acquire time in nanoseconds. 106 * 107 * The average lock acquire time is the total acquire time divided by the 108 * lock usage count. The ration of the total section and total acquire times 109 * gives a measure for the lock contention. 110 * 111 * This value may overflow. 112 */ 113 uint64_t total_acquire_time; 114 115 /** 116 * @brief The counts of lock acquire operations by contention. 117 * 118 * The contention count for index N corresponds to a lock acquire attempt 119 * with an initial queue length of N. The last index corresponds to all 120 * lock acquire attempts with an initial queue length greater than or equal 121 * to SMP_LOCK_STATS_CONTENTION_COUNTS minus one. 122 * 123 * The values may overflow. 124 */ 125 uint64_t contention_counts[SMP_LOCK_STATS_CONTENTION_COUNTS]; 126 127 /** 128 * @brief Total lock section time in CPU counter ticks. 129 * 130 * The average lock section time is the total section time divided by the 131 * lock usage count. 132 * 133 * This value may overflow. 134 */ 135 uint64_t total_section_time; 136 137 /** 138 * @brief The lock name. 139 */ 140 const char *name; 141 #endif /* defined( RTEMS_PROFILING ) */ 142 } SMP_lock_Stats; 143 144 /** 145 * @brief Local context for SMP lock statistics. 146 */ 147 typedef struct { 148 #if defined( RTEMS_PROFILING ) 149 /** 150 * @brief The last lock acquire instant in CPU counter ticks. 151 * 152 * This value is used to measure the lock section time. 153 */ 154 CPU_Counter_ticks acquire_instant; 155 #endif 156 } SMP_lock_Stats_context; 157 158 /** 159 * @brief SMP lock statistics initializer for static initialization. 160 */ 161 #if defined( RTEMS_PROFILING ) 162 #define SMP_LOCK_STATS_INITIALIZER( name ) \ 163 { { NULL, NULL }, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, name } 164 #else 165 #define SMP_LOCK_STATS_INITIALIZER( name ) \ 166 { } 167 #endif 168 169 /** 170 * @brief Initializes an SMP lock statistics block. 171 * 172 * @param[in, out] stats The SMP lock statistics block. 173 * @param[in] name The name for the SMP lock statistics. This name must be 174 * persistent throughout the life time of this statistics block. 175 */ 176 static inline void _SMP_lock_Stats_initialize( 177 SMP_lock_Stats *stats, 178 const char *name 179 ) 180 { 181 SMP_lock_Stats init = SMP_LOCK_STATS_INITIALIZER( name ); 182 183 *stats = init; 184 } 185 186 /** 187 * @brief Destroys an SMP lock statistics block. 188 * 189 * @param[in,out] stats The SMP lock statistics block. 190 */ 191 static inline void _SMP_lock_Stats_destroy( SMP_lock_Stats *stats ); 192 193 /** 194 * @brief Destroys an SMP lock statistics block. 195 * 196 * @param[in,out] stats The SMP lock statistics block. 197 * @param[in] stats_context The SMP lock statistics context. 198 */ 199 static inline void _SMP_lock_Stats_release_update( 200 SMP_lock_Stats *stats, 201 const SMP_lock_Stats_context *stats_context 202 ); 203 204 /** 53 205 * @brief SMP ticket lock control. 54 206 */ … … 56 208 Atomic_Uint next_ticket; 57 209 Atomic_Uint now_serving; 210 SMP_lock_Stats Stats; 58 211 } SMP_ticket_lock_Control; 59 212 … … 61 214 * @brief SMP ticket lock control initializer for static initialization. 62 215 */ 63 #define SMP_TICKET_LOCK_INITIALIZER \ 64 { ATOMIC_INITIALIZER_UINT( 0U ), ATOMIC_INITIALIZER_UINT( 0U ) } 216 #define SMP_TICKET_LOCK_INITIALIZER( name ) \ 217 { \ 218 ATOMIC_INITIALIZER_UINT( 0U ), \ 219 ATOMIC_INITIALIZER_UINT( 0U ), \ 220 SMP_LOCK_STATS_INITIALIZER( name ) \ 221 } 65 222 66 223 /** … … 70 227 * 71 228 * @param[in,out] lock The SMP ticket lock control. 72 */ 73 static inline void _SMP_ticket_lock_Initialize( SMP_ticket_lock_Control *lock ) 229 * @param[in] name The name for the SMP ticket lock. This name must be 230 * persistent throughout the life time of this lock. 231 */ 232 static inline void _SMP_ticket_lock_Initialize( 233 SMP_ticket_lock_Control *lock, 234 const char *name 235 ) 74 236 { 75 237 _Atomic_Init_uint( &lock->next_ticket, 0U ); 76 238 _Atomic_Init_uint( &lock->now_serving, 0U ); 239 _SMP_lock_Stats_initialize( &lock->Stats, name ); 77 240 } 78 241 … … 86 249 static inline void _SMP_ticket_lock_Destroy( SMP_ticket_lock_Control *lock ) 87 250 { 88 (void) lock;251 _SMP_lock_Stats_destroy( &lock->Stats ); 89 252 } 90 253 … … 97 260 * 98 261 * @param[in,out] lock The SMP ticket lock control. 99 */ 100 static inline void _SMP_ticket_lock_Acquire( SMP_ticket_lock_Control *lock ) 101 { 102 unsigned int my_ticket = 262 * @param[out] stats_context The SMP lock statistics context. 263 */ 264 static inline void _SMP_ticket_lock_Acquire( 265 SMP_ticket_lock_Control *lock, 266 SMP_lock_Stats_context *stats_context 267 ) 268 { 269 unsigned int my_ticket; 270 unsigned int now_serving; 271 272 #if defined( RTEMS_PROFILING ) 273 SMP_lock_Stats *stats = &lock->Stats; 274 CPU_Counter_ticks first; 275 CPU_Counter_ticks second; 276 CPU_Counter_ticks delta; 277 unsigned int initial_queue_length; 278 279 first = _CPU_Counter_read(); 280 #endif 281 282 my_ticket = 103 283 _Atomic_Fetch_add_uint( &lock->next_ticket, 1U, ATOMIC_ORDER_RELAXED ); 104 unsigned int now_serving; 105 106 do { 107 now_serving = 108 _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); 109 } while ( now_serving != my_ticket ); 284 285 #if defined( RTEMS_PROFILING ) 286 now_serving = 287 _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); 288 initial_queue_length = my_ticket - now_serving; 289 290 if ( initial_queue_length > 0 ) { 291 #endif 292 293 do { 294 now_serving = 295 _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); 296 } while ( now_serving != my_ticket ); 297 298 #if defined( RTEMS_PROFILING ) 299 } 300 301 second = _CPU_Counter_read(); 302 stats_context->acquire_instant = second; 303 delta = _CPU_Counter_difference( second, first ); 304 305 ++stats->usage_count; 306 307 stats->total_acquire_time += delta; 308 309 if ( stats->max_acquire_time < delta ) { 310 stats->max_acquire_time = delta; 311 } 312 313 if ( initial_queue_length >= SMP_LOCK_STATS_CONTENTION_COUNTS ) { 314 initial_queue_length = SMP_LOCK_STATS_CONTENTION_COUNTS - 1; 315 } 316 ++stats->contention_counts[initial_queue_length]; 317 #else 318 (void) stats_context; 319 #endif 110 320 } 111 321 … … 114 324 * 115 325 * @param[in,out] lock The SMP ticket lock control. 116 */ 117 static inline void _SMP_ticket_lock_Release( SMP_ticket_lock_Control *lock ) 326 * @param[in] stats_context The SMP lock statistics context. 327 */ 328 static inline void _SMP_ticket_lock_Release( 329 SMP_ticket_lock_Control *lock, 330 const SMP_lock_Stats_context *stats_context 331 ) 118 332 { 119 333 unsigned int current_ticket = … … 121 335 unsigned int next_ticket = current_ticket + 1U; 122 336 337 _SMP_lock_Stats_release_update( &lock->Stats, stats_context ); 338 123 339 _Atomic_Store_uint( &lock->now_serving, next_ticket, ATOMIC_ORDER_RELEASE ); 124 340 } … … 136 352 typedef struct { 137 353 ISR_Level isr_level; 354 SMP_lock_Stats_context Stats_context; 138 355 } SMP_lock_Context; 139 356 … … 141 358 * @brief SMP lock control initializer for static initialization. 142 359 */ 143 #define SMP_LOCK_INITIALIZER { SMP_TICKET_LOCK_INITIALIZER}360 #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER( name ) } 144 361 145 362 /** … … 149 366 * 150 367 * @param[in,out] lock The SMP lock control. 151 */ 152 static inline void _SMP_lock_Initialize( SMP_lock_Control *lock ) 153 { 154 _SMP_ticket_lock_Initialize( &lock->ticket_lock ); 368 * @param[in] name The name for the SMP lock statistics. This name must be 369 * persistent throughout the life time of this statistics block. 370 */ 371 static inline void _SMP_lock_Initialize( 372 SMP_lock_Control *lock, 373 const char *name 374 ) 375 { 376 _SMP_ticket_lock_Initialize( &lock->ticket_lock, name ); 155 377 } 156 378 … … 184 406 { 185 407 (void) context; 186 _SMP_ticket_lock_Acquire( &lock->ticket_lock );408 _SMP_ticket_lock_Acquire( &lock->ticket_lock, &context->Stats_context ); 187 409 } 188 410 … … 200 422 { 201 423 (void) context; 202 _SMP_ticket_lock_Release( &lock->ticket_lock );424 _SMP_ticket_lock_Release( &lock->ticket_lock, &context->Stats_context ); 203 425 } 204 426 … … 235 457 } 236 458 459 #if defined( RTEMS_PROFILING ) 460 typedef struct { 461 SMP_lock_Control Lock; 462 Chain_Control Stats_chain; 463 Chain_Control Iterator_chain; 464 } SMP_lock_Stats_control; 465 466 typedef struct { 467 Chain_Node Node; 468 SMP_lock_Stats *current; 469 } SMP_lock_Stats_iteration_context; 470 471 extern SMP_lock_Stats_control _SMP_lock_Stats_control; 472 473 static inline void _SMP_lock_Stats_iteration_start( 474 SMP_lock_Stats_iteration_context *iteration_context 475 ) 476 { 477 SMP_lock_Stats_control *control = &_SMP_lock_Stats_control; 478 SMP_lock_Context lock_context; 479 480 _SMP_lock_ISR_disable_and_acquire( &control->Lock, &lock_context ); 481 482 _Chain_Append_unprotected( 483 &control->Iterator_chain, 484 &iteration_context->Node 485 ); 486 iteration_context->current = 487 (SMP_lock_Stats *) _Chain_First( &control->Stats_chain ); 488 489 _SMP_lock_Release_and_ISR_enable( &control->Lock, &lock_context ); 490 } 491 492 static inline bool _SMP_lock_Stats_iteration_next( 493 SMP_lock_Stats_iteration_context *iteration_context, 494 SMP_lock_Stats *snapshot, 495 char *name, 496 size_t name_size 497 ) 498 { 499 SMP_lock_Stats_control *control = &_SMP_lock_Stats_control; 500 SMP_lock_Context lock_context; 501 SMP_lock_Stats *current; 502 bool valid; 503 504 _SMP_lock_ISR_disable_and_acquire( &control->Lock, &lock_context ); 505 506 current = iteration_context->current; 507 if ( !_Chain_Is_tail( &control->Stats_chain, ¤t->Node ) ) { 508 size_t name_len = strlen(current->name); 509 510 valid = true; 511 512 iteration_context->current = (SMP_lock_Stats *) 513 _Chain_Next( ¤t->Node ); 514 515 *snapshot = *current; 516 snapshot->name = name; 517 518 if ( name_len >= name_size ) { 519 name_len = name_size - 1; 520 } 521 522 name[name_len] = '\0'; 523 memcpy(name, current->name, name_len); 524 } else { 525 valid = false; 526 } 527 528 _SMP_lock_Release_and_ISR_enable( &control->Lock, &lock_context ); 529 530 return valid; 531 } 532 533 static inline void _SMP_lock_Stats_iteration_stop( 534 SMP_lock_Stats_iteration_context *iteration_context 535 ) 536 { 537 SMP_lock_Stats_control *control = &_SMP_lock_Stats_control; 538 SMP_lock_Context lock_context; 539 540 _SMP_lock_ISR_disable_and_acquire( &control->Lock, &lock_context ); 541 _Chain_Extract_unprotected( &iteration_context->Node ); 542 _SMP_lock_Release_and_ISR_enable( &control->Lock, &lock_context ); 543 } 544 #endif 545 546 static inline void _SMP_lock_Stats_destroy( SMP_lock_Stats *stats ) 547 { 548 #if defined( RTEMS_PROFILING ) 549 if ( !_Chain_Is_node_off_chain( &stats->Node ) ) { 550 SMP_lock_Stats_control *control = &_SMP_lock_Stats_control; 551 SMP_lock_Context lock_context; 552 SMP_lock_Stats_iteration_context *iteration_context; 553 SMP_lock_Stats_iteration_context *iteration_context_tail; 554 SMP_lock_Stats *next_stats; 555 556 _SMP_lock_ISR_disable_and_acquire( &control->Lock, &lock_context ); 557 558 next_stats = (SMP_lock_Stats *) _Chain_Next( &stats->Node ); 559 _Chain_Extract_unprotected( &stats->Node ); 560 561 iteration_context = (SMP_lock_Stats_iteration_context *) 562 _Chain_First( &control->Iterator_chain ); 563 iteration_context_tail = (SMP_lock_Stats_iteration_context *) 564 _Chain_Tail( &control->Iterator_chain ); 565 566 while ( iteration_context != iteration_context_tail ) { 567 if ( iteration_context->current == stats ) { 568 iteration_context->current = next_stats; 569 } 570 571 iteration_context = (SMP_lock_Stats_iteration_context *) 572 _Chain_Next( &iteration_context->Node ); 573 } 574 575 _SMP_lock_Release_and_ISR_enable( &control->Lock, &lock_context ); 576 } 577 #else 578 (void) stats; 579 #endif 580 } 581 582 static inline void _SMP_lock_Stats_release_update( 583 SMP_lock_Stats *stats, 584 const SMP_lock_Stats_context *stats_context 585 ) 586 { 587 #if defined( RTEMS_PROFILING ) 588 CPU_Counter_ticks first = stats_context->acquire_instant; 589 CPU_Counter_ticks second = _CPU_Counter_read(); 590 CPU_Counter_ticks delta = _CPU_Counter_difference( second, first ); 591 592 stats->total_section_time += delta; 593 594 if ( stats->max_section_time < delta ) { 595 stats->max_section_time = delta; 596 597 if ( _Chain_Is_node_off_chain( &stats->Node ) ) { 598 SMP_lock_Stats_control *control = &_SMP_lock_Stats_control; 599 SMP_lock_Context lock_context; 600 601 _SMP_lock_ISR_disable_and_acquire( &control->Lock, &lock_context ); 602 _Chain_Append_unprotected( &control->Stats_chain, &stats->Node ); 603 _SMP_lock_Release_and_ISR_enable( &control->Lock, &lock_context ); 604 } 605 } 606 #else 607 (void) stats; 608 (void) stats_context; 609 #endif 610 } 611 237 612 /**@}*/ 238 613 -
cpukit/score/src/coretod.c
rf980561 r53ad908 30 30 TOD_Control *tod = &_TOD; 31 31 32 _ISR_lock_Initialize( &tod->lock );32 _ISR_lock_Initialize( &tod->lock, "TOD" ); 33 33 34 34 _Timestamp_Set( &tod->now, TOD_SECONDS_1970_THROUGH_1988, 0 ); -
cpukit/score/src/percpu.c
rf980561 r53ad908 27 27 #if defined(RTEMS_SMP) 28 28 29 static SMP_lock_Control _Per_CPU_State_lock = SMP_LOCK_INITIALIZER; 29 static SMP_lock_Control _Per_CPU_State_lock = 30 SMP_LOCK_INITIALIZER("per-CPU state"); 30 31 31 32 static void _Per_CPU_State_busy_wait( -
cpukit/score/src/smp.c
rf980561 r53ad908 33 33 Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); 34 34 35 _SMP_ticket_lock_Initialize( &per_cpu->Lock );35 _SMP_ticket_lock_Initialize( &per_cpu->Lock, "per-CPU" ); 36 36 } 37 37 -
cpukit/score/src/threaddispatchdisablelevel.c
rf980561 r53ad908 30 30 31 31 static Giant_Control _Giant = { 32 .lock = SMP_LOCK_INITIALIZER ,32 .lock = SMP_LOCK_INITIALIZER("Giant"), 33 33 .owner_cpu = NO_OWNER_CPU, 34 34 .nest_level = 0 -
cpukit/score/src/threadhandler.c
rf980561 r53ad908 57 57 58 58 #if defined(RTEMS_SMP) 59 static SMP_lock_Control constructor_lock = SMP_LOCK_INITIALIZER; 59 static SMP_lock_Control constructor_lock = 60 SMP_LOCK_INITIALIZER("constructor"); 60 61 61 62 SMP_lock_Context lock_context; -
testsuites/smptests/smplock01/init.c
rf980561 r53ad908 49 49 .state = ATOMIC_INITIALIZER_UINT(INITIAL), 50 50 .barrier = SMP_BARRIER_CONTROL_INITIALIZER, 51 .lock = SMP_LOCK_INITIALIZER 51 .lock = SMP_LOCK_INITIALIZER("global") 52 52 }; 53 53 … … 142 142 SMP_lock_Context lock_context; 143 143 144 _SMP_lock_Initialize(&lock );144 _SMP_lock_Initialize(&lock, "local"); 145 145 146 146 while (assert_state(ctx, START_TEST)) { … … 167 167 SMP_lock_Context lock_context; 168 168 169 _SMP_lock_Initialize(&lock );169 _SMP_lock_Initialize(&lock, "local"); 170 170 171 171 while (assert_state(ctx, START_TEST)) { -
testsuites/sptests/sp37/init.c
rf980561 r53ad908 161 161 { 162 162 ISR_Level normal_interrupt_level = _ISR_Get_level(); 163 ISR_lock_Control initialized = ISR_LOCK_INITIALIZER ;163 ISR_lock_Control initialized = ISR_LOCK_INITIALIZER("test"); 164 164 ISR_lock_Control lock; 165 165 ISR_lock_Context lock_context; 166 166 167 _ISR_lock_Initialize( &lock );167 _ISR_lock_Initialize( &lock, "test" ); 168 168 rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 ); 169 169 … … 198 198 { 199 199 rtems_mode normal_interrupt_level = get_interrupt_level(); 200 rtems_interrupt_lock initialized = RTEMS_INTERRUPT_LOCK_INITIALIZER ;200 rtems_interrupt_lock initialized = RTEMS_INTERRUPT_LOCK_INITIALIZER("test"); 201 201 rtems_interrupt_lock lock; 202 202 rtems_interrupt_lock_context lock_context; 203 203 204 rtems_interrupt_lock_initialize( &lock );204 rtems_interrupt_lock_initialize( &lock, "test" ); 205 205 rtems_test_assert( memcmp( &lock, &initialized, sizeof( lock ) ) == 0 ); 206 206 -
testsuites/sptests/spcache01/init.c
rf980561 r53ad908 49 49 printf("data cache flush and invalidate test\n"); 50 50 51 rtems_interrupt_lock_initialize(&lock );51 rtems_interrupt_lock_initialize(&lock, "test"); 52 52 rtems_interrupt_lock_acquire(&lock, &lock_context); 53 53 … … 169 169 size_t cache_size; 170 170 171 rtems_interrupt_lock_initialize(&lock );171 rtems_interrupt_lock_initialize(&lock, "test"); 172 172 173 173 printf( -
testsuites/sptests/spnsext01/init.c
rf980561 r53ad908 52 52 n = (3 * n) / 2; 53 53 54 rtems_interrupt_lock_initialize(&lock );54 rtems_interrupt_lock_initialize(&lock, "test"); 55 55 rtems_interrupt_lock_acquire(&lock, &lock_context); 56 56 sc = rtems_clock_get_uptime(&uptime); -
testsuites/sptests/spprofiling01/init.c
rf980561 r53ad908 22 22 23 23 #include <stdio.h> 24 #include <string.h> 24 25 25 26 #include "tmacros.h" 26 27 27 static void test(void) 28 typedef struct { 29 rtems_interrupt_lock a; 30 rtems_interrupt_lock b; 31 rtems_interrupt_lock c; 32 rtems_interrupt_lock d; 33 enum { 34 WAIT_FOR_A, 35 EXPECT_B, 36 EXPECT_D, 37 DONE 38 } state; 39 } visitor_context; 40 41 static bool is_equal(const rtems_profiling_smp_lock *psl, const char *name) 42 { 43 return strcmp(psl->name, name) == 0; 44 } 45 46 static void visitor(void *arg, const rtems_profiling_data *data) 47 { 48 visitor_context *ctx = arg; 49 50 if (data->header.type == RTEMS_PROFILING_SMP_LOCK) { 51 const rtems_profiling_smp_lock *psl = &data->smp_lock; 52 53 switch (ctx->state) { 54 case WAIT_FOR_A: 55 rtems_test_assert(!is_equal(psl, "b")); 56 rtems_test_assert(!is_equal(psl, "c")); 57 rtems_test_assert(!is_equal(psl, "d")); 58 59 if (is_equal(psl, "a")) { 60 ctx->state = EXPECT_B; 61 } 62 break; 63 case EXPECT_B: 64 rtems_test_assert(is_equal(psl, "b")); 65 rtems_interrupt_lock_destroy(&ctx->c); 66 ctx->state = EXPECT_D; 67 break; 68 case EXPECT_D: 69 rtems_test_assert(is_equal(psl, "d")); 70 ctx->state = DONE; 71 break; 72 case DONE: 73 rtems_test_assert(!is_equal(psl, "a")); 74 rtems_test_assert(!is_equal(psl, "b")); 75 rtems_test_assert(!is_equal(psl, "c")); 76 rtems_test_assert(!is_equal(psl, "d")); 77 break; 78 } 79 } 80 } 81 82 static void lock_init(rtems_interrupt_lock *lock, const char *name) 83 { 84 rtems_interrupt_lock_context lock_context; 85 86 rtems_interrupt_lock_initialize(lock, name); 87 rtems_interrupt_lock_acquire(lock, &lock_context); 88 rtems_interrupt_lock_release(lock, &lock_context); 89 } 90 91 static void test_iterate(void) 92 { 93 visitor_context ctx_instance; 94 visitor_context *ctx = &ctx_instance; 95 96 ctx->state = WAIT_FOR_A; 97 lock_init(&ctx->a, "a"); 98 lock_init(&ctx->b, "b"); 99 lock_init(&ctx->c, "c"); 100 lock_init(&ctx->d, "d"); 101 102 rtems_profiling_iterate(visitor, ctx); 103 104 rtems_interrupt_lock_destroy(&ctx->a); 105 rtems_interrupt_lock_destroy(&ctx->b); 106 107 if (ctx->state != DONE) { 108 rtems_interrupt_lock_destroy(&ctx->c); 109 } 110 111 rtems_interrupt_lock_destroy(&ctx->d); 112 } 113 114 static void test_report_xml(void) 28 115 { 29 116 rtems_status_code sc; … … 41 128 puts("\n\n*** TEST SPPROFILING 1 ***"); 42 129 43 test(); 130 test_iterate(); 131 test_report_xml(); 44 132 45 133 puts("*** END OF TEST SPPROFILING 1 ***"); -
testsuites/tmtests/tmcontext01/init.c
rf980561 r53ad908 139 139 uint64_t max; 140 140 141 rtems_interrupt_lock_initialize(&lock );141 rtems_interrupt_lock_initialize(&lock, "test"); 142 142 rtems_interrupt_lock_acquire(&lock, &lock_context); 143 143
Note: See TracChangeset
for help on using the changeset viewer.