Changeset c2ab3f4 in mainline for kernel/generic/src/sysinfo/stats.c


Ignore:
Timestamp:
2010-04-28T21:12:04Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c050399
Parents:
b8f7ea78 (diff), 55821eea (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge blocking and locking improvements and fixes.

File:
1 edited

Legend:

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

    rb8f7ea78 rc2ab3f4  
    3838#include <sysinfo/stats.h>
    3939#include <sysinfo/sysinfo.h>
     40#include <synch/spinlock.h>
     41#include <synch/mutex.h>
    4042#include <time/clock.h>
    4143#include <mm/frame.h>
     
    6870static load_t avenrdy[LOAD_STEPS] = {0, 0, 0};
    6971
    70 /** Load calculation spinlock */
    71 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");
     72/** Load calculation lock */
     73static mutex_t load_lock;
    7274
    7375/** Get system uptime
     
    344346       
    345347        /* Interrupts are already disabled */
    346         spinlock_lock(&(thread->lock));
     348        spinlock_lock(&thread->lock);
    347349       
    348350        /* Record the statistics and increment the iterator */
     
    350352        (*iterator)++;
    351353       
    352         spinlock_unlock(&(thread->lock));
     354        spinlock_unlock(&thread->lock);
    353355       
    354356        return true;
     
    615617        }
    616618       
    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);
    620621       
    621622        unsigned int i;
     
    623624                stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT;
    624625       
    625         spinlock_unlock(&load_lock);
    626         interrupts_restore(ipl);
     626        mutex_unlock(&load_lock);
    627627       
    628628        return ((void *) stats_load);
     
    655655               
    656656                /* Mutually exclude with get_stats_load() */
    657                 ipl_t ipl = interrupts_disable();
    658                 spinlock_lock(&load_lock);
     657                mutex_lock(&load_lock);
    659658               
    660659                unsigned int i;
     
    662661                        avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready);
    663662               
    664                 spinlock_unlock(&load_lock);
    665                 interrupts_restore(ipl);
     663                mutex_unlock(&load_lock);
    666664               
    667665                thread_sleep(LOAD_INTERVAL);
     
    674672void stats_init(void)
    675673{
     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.