Changes in kernel/generic/src/sysinfo/stats.c [6e121b8:acda8f0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/stats.c
r6e121b8 racda8f0 38 38 #include <sysinfo/stats.h> 39 39 #include <sysinfo/sysinfo.h> 40 #include <synch/spinlock.h>41 #include <synch/mutex.h>42 40 #include <time/clock.h> 43 41 #include <mm/frame.h> … … 70 68 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0}; 71 69 72 /** Load calculation lock */73 static mutex_t load_lock;70 /** Load calculation spinlock */ 71 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock"); 74 72 75 73 /** Get system uptime … … 346 344 347 345 /* Interrupts are already disabled */ 348 spinlock_lock(& thread->lock);346 spinlock_lock(&(thread->lock)); 349 347 350 348 /* Record the statistics and increment the iterator */ … … 352 350 (*iterator)++; 353 351 354 spinlock_unlock(& thread->lock);352 spinlock_unlock(&(thread->lock)); 355 353 356 354 return true; … … 617 615 } 618 616 619 /* To always get consistent values acquire the mutex */ 620 mutex_lock(&load_lock); 617 /* To always get consistent values acquire the spinlock */ 618 ipl_t ipl = interrupts_disable(); 619 spinlock_lock(&load_lock); 621 620 622 621 unsigned int i; … … 624 623 stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT; 625 624 626 mutex_unlock(&load_lock); 625 spinlock_unlock(&load_lock); 626 interrupts_restore(ipl); 627 627 628 628 return ((void *) stats_load); … … 655 655 656 656 /* Mutually exclude with get_stats_load() */ 657 mutex_lock(&load_lock); 657 ipl_t ipl = interrupts_disable(); 658 spinlock_lock(&load_lock); 658 659 659 660 unsigned int i; … … 661 662 avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready); 662 663 663 mutex_unlock(&load_lock); 664 spinlock_unlock(&load_lock); 665 interrupts_restore(ipl); 664 666 665 667 thread_sleep(LOAD_INTERVAL); … … 672 674 void stats_init(void) 673 675 { 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.