comparison packages/kernel/current/src/common/clock.cxx @ 1077:e4850e482c80

* src/common/clock.cxx (Cyg_Counter::rem_alarm): Bugfix: call Cyg_Scheduler::lock() before calculation of index into alarm_list array to avoid race condition with multi list counters.
author jlarmour
date Wed, 25 Jun 2003 17:44:28 +0000
parents b77e86276ec3
children 4c13726203c5
comparison
equal deleted inserted replaced
1076:ff838098079a 1077:e4850e482c80
169 #else 169 #else
170 #error "No CYGIMP_KERNEL_COUNTERS_x_LIST config" 170 #error "No CYGIMP_KERNEL_COUNTERS_x_LIST config"
171 #endif 171 #endif
172 172
173 // Now that we have the list pointer, we can use common code for 173 // Now that we have the list pointer, we can use common code for
174 // both list oragnizations. 174 // both list organizations.
175 175
176 #ifdef CYGIMP_KERNEL_COUNTERS_SORT_LIST 176 #ifdef CYGIMP_KERNEL_COUNTERS_SORT_LIST
177 177
178 // With a sorted alarm list, we can simply pick alarms off the 178 // With a sorted alarm list, we can simply pick alarms off the
179 // front of the list until we find one that is in the future. 179 // front of the list until we find one that is in the future.
398 Cyg_Alarm_List *alarm_list_ptr; // pointer to list 398 Cyg_Alarm_List *alarm_list_ptr; // pointer to list
399 399
400 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST) 400 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST)
401 401
402 alarm_list_ptr = &alarm_list; 402 alarm_list_ptr = &alarm_list;
403 Cyg_Scheduler::lock();
403 404
404 #elif defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST) 405 #elif defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST)
406
407 Cyg_Scheduler::lock();
405 408
406 alarm_list_ptr = &(alarm_list[ 409 alarm_list_ptr = &(alarm_list[
407 ((alarm->trigger+increment-1)/increment) % 410 ((alarm->trigger+increment-1)/increment) %
408 CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE ] ); 411 CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE ] );
409 412
411 #error "No CYGIMP_KERNEL_COUNTERS_x_LIST config" 414 #error "No CYGIMP_KERNEL_COUNTERS_x_LIST config"
412 #endif 415 #endif
413 416
414 // Now that we have the list pointer, we can use common code for 417 // Now that we have the list pointer, we can use common code for
415 // both list organizations. 418 // both list organizations.
416
417 Cyg_Scheduler::lock();
418 419
419 CYG_INSTRUMENT_ALARM( REM, this, alarm ); 420 CYG_INSTRUMENT_ALARM( REM, this, alarm );
420 421
421 alarm_list_ptr->remove( alarm ); 422 alarm_list_ptr->remove( alarm );
422 423