Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/sysinfo/stats.c

    r6e121b8 racda8f0  
    3838#include <sysinfo/stats.h>
    3939#include <sysinfo/sysinfo.h>
    40 #include <synch/spinlock.h>
    41 #include <synch/mutex.h>
    4240#include <time/clock.h>
    4341#include <mm/frame.h>
     
    7068static load_t avenrdy[LOAD_STEPS] = {0, 0, 0};
    7169
    72 /** Load calculation lock */
    73 static mutex_t load_lock;
     70/** Load calculation spinlock */
     71SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");
    7472
    7573/** Get system uptime
     
    346344       
    347345        /* Interrupts are already disabled */
    348         spinlock_lock(&thread->lock);
     346        spinlock_lock(&(thread->lock));
    349347       
    350348        /* Record the statistics and increment the iterator */
     
    352350        (*iterator)++;
    353351       
    354         spinlock_unlock(&thread->lock);
     352        spinlock_unlock(&(thread->lock));
    355353       
    356354        return true;
     
    617615        }
    618616       
    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);
    621620       
    622621        unsigned int i;
     
    624623                stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT;
    625624       
    626         mutex_unlock(&load_lock);
     625        spinlock_unlock(&load_lock);
     626        interrupts_restore(ipl);
    627627       
    628628        return ((void *) stats_load);
     
    655655               
    656656                /* Mutually exclude with get_stats_load() */
    657                 mutex_lock(&load_lock);
     657                ipl_t ipl = interrupts_disable();
     658                spinlock_lock(&load_lock);
    658659               
    659660                unsigned int i;
     
    661662                        avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready);
    662663               
    663                 mutex_unlock(&load_lock);
     664                spinlock_unlock(&load_lock);
     665                interrupts_restore(ipl);
    664666               
    665667                thread_sleep(LOAD_INTERVAL);
     
    672674void stats_init(void)
    673675{
    674         mutex_initialize(&load_lock, MUTEX_PASSIVE);
    675 
    676676        sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime);
    677677        sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus);
Note: See TracChangeset for help on using the changeset viewer.