Changes in kernel/generic/src/sysinfo/stats.c [6e121b8:9efff92] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/stats.c
r6e121b8 r9efff92 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 … … 158 156 static size_t get_task_virtmem(as_t *as) 159 157 { 158 mutex_lock(&as->lock); 159 160 160 size_t result = 0; 161 162 /*163 * We are holding some spinlocks here and therefore are not allowed to164 * block. Only attempt to lock the address space and address space area165 * mutexes conditionally. If it is not possible to lock either object,166 * allow the statistics to be inexact by skipping the respective object.167 *168 * Note that it may be infinitely better to let the address space169 * management code compute these statistics as it proceeds instead of170 * having them calculated here over and over again here.171 */172 173 if (SYNCH_FAILED(mutex_trylock(&as->lock)))174 return result * PAGE_SIZE;175 161 176 162 /* Walk the B+ tree and count pages */ … … 185 171 as_area_t *area = node->value[i]; 186 172 187 if (SYNCH_FAILED(mutex_trylock(&area->lock))) 188 continue; 173 mutex_lock(&area->lock); 189 174 result += area->pages; 190 175 mutex_unlock(&area->lock); … … 346 331 347 332 /* Interrupts are already disabled */ 348 spinlock_lock(& thread->lock);333 spinlock_lock(&(thread->lock)); 349 334 350 335 /* Record the statistics and increment the iterator */ … … 352 337 (*iterator)++; 353 338 354 spinlock_unlock(& thread->lock);339 spinlock_unlock(&(thread->lock)); 355 340 356 341 return true; … … 617 602 } 618 603 619 /* To always get consistent values acquire the mutex */ 620 mutex_lock(&load_lock); 604 /* To always get consistent values acquire the spinlock */ 605 ipl_t ipl = interrupts_disable(); 606 spinlock_lock(&load_lock); 621 607 622 608 unsigned int i; … … 624 610 stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT; 625 611 626 mutex_unlock(&load_lock); 612 spinlock_unlock(&load_lock); 613 interrupts_restore(ipl); 627 614 628 615 return ((void *) stats_load); … … 655 642 656 643 /* Mutually exclude with get_stats_load() */ 657 mutex_lock(&load_lock); 644 ipl_t ipl = interrupts_disable(); 645 spinlock_lock(&load_lock); 658 646 659 647 unsigned int i; … … 661 649 avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready); 662 650 663 mutex_unlock(&load_lock); 651 spinlock_unlock(&load_lock); 652 interrupts_restore(ipl); 664 653 665 654 thread_sleep(LOAD_INTERVAL); … … 672 661 void stats_init(void) 673 662 { 674 mutex_initialize(&load_lock, MUTEX_PASSIVE);675 676 663 sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime); 677 664 sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus);
Note:
See TracChangeset
for help on using the changeset viewer.