Changeset 6e121b8 in mainline
- Timestamp:
- 2010-04-28T19:55:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c6218327
- Parents:
- 6b6626d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/stats.c
r6b6626d3 r6e121b8 38 38 #include <sysinfo/stats.h> 39 39 #include <sysinfo/sysinfo.h> 40 #include <synch/spinlock.h> 41 #include <synch/mutex.h> 40 42 #include <time/clock.h> 41 43 #include <mm/frame.h> … … 68 70 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0}; 69 71 70 /** Load calculation spinlock */71 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");72 /** Load calculation lock */ 73 static mutex_t load_lock; 72 74 73 75 /** Get system uptime … … 344 346 345 347 /* Interrupts are already disabled */ 346 spinlock_lock(& (thread->lock));348 spinlock_lock(&thread->lock); 347 349 348 350 /* Record the statistics and increment the iterator */ … … 350 352 (*iterator)++; 351 353 352 spinlock_unlock(& (thread->lock));354 spinlock_unlock(&thread->lock); 353 355 354 356 return true; … … 615 617 } 616 618 617 /* To always get consistent values acquire the spinlock */ 618 ipl_t ipl = interrupts_disable(); 619 spinlock_lock(&load_lock); 619 /* To always get consistent values acquire the mutex */ 620 mutex_lock(&load_lock); 620 621 621 622 unsigned int i; … … 623 624 stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT; 624 625 625 spinlock_unlock(&load_lock); 626 interrupts_restore(ipl); 626 mutex_unlock(&load_lock); 627 627 628 628 return ((void *) stats_load); … … 655 655 656 656 /* Mutually exclude with get_stats_load() */ 657 ipl_t ipl = interrupts_disable(); 658 spinlock_lock(&load_lock); 657 mutex_lock(&load_lock); 659 658 660 659 unsigned int i; … … 662 661 avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready); 663 662 664 spinlock_unlock(&load_lock); 665 interrupts_restore(ipl); 663 mutex_unlock(&load_lock); 666 664 667 665 thread_sleep(LOAD_INTERVAL); … … 674 672 void stats_init(void) 675 673 { 674 mutex_initialize(&load_lock, MUTEX_PASSIVE); 675 676 676 sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime); 677 677 sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus);
Note:
See TracChangeset
for help on using the changeset viewer.