Ignore:
File:
1 edited

Legend:

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

    rc6218327 rb4ad39f  
    3737#include <print.h>
    3838#include <syscall/copy.h>
    39 #include <synch/mutex.h>
     39#include <synch/spinlock.h>
    4040#include <arch/asm.h>
    4141#include <errno.h>
     
    5252static slab_cache_t *sysinfo_item_slab;
    5353
    54 /** Sysinfo lock */
    55 static mutex_t sysinfo_lock;
     54/** Sysinfo spinlock */
     55SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");
    5656
    5757/** Sysinfo item constructor
     
    9898            sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
    9999            sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
    100 
    101         mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE);
    102100}
    103101
    104102/** Recursively find an item in sysinfo tree
    105103 *
    106  * Should be called with sysinfo_lock held.
     104 * Should be called with interrupts disabled
     105 * and sysinfo_lock held.
    107106 *
    108107 * @param name    Current sysinfo path suffix.
     
    169168/** Recursively create items in sysinfo tree
    170169 *
    171  * Should be called with sysinfo_lock held.
     170 * Should be called with interrupts disabled
     171 * and sysinfo_lock held.
    172172 *
    173173 * @param name     Current sysinfo path suffix.
     
    299299{
    300300        /* Protect sysinfo tree consistency */
    301         mutex_lock(&sysinfo_lock);
     301        ipl_t ipl = interrupts_disable();
     302        spinlock_lock(&sysinfo_lock);
    302303       
    303304        if (root == NULL)
     
    310311        }
    311312       
    312         mutex_unlock(&sysinfo_lock);
     313        spinlock_unlock(&sysinfo_lock);
     314        interrupts_restore(ipl);
    313315}
    314316
     
    330332{
    331333        /* Protect sysinfo tree consistency */
    332         mutex_lock(&sysinfo_lock);
     334        ipl_t ipl = interrupts_disable();
     335        spinlock_lock(&sysinfo_lock);
    333336       
    334337        if (root == NULL)
     
    342345        }
    343346       
    344         mutex_unlock(&sysinfo_lock);
     347        spinlock_unlock(&sysinfo_lock);
     348        interrupts_restore(ipl);
    345349}
    346350
     
    357361{
    358362        /* Protect sysinfo tree consistency */
    359         mutex_lock(&sysinfo_lock);
     363        ipl_t ipl = interrupts_disable();
     364        spinlock_lock(&sysinfo_lock);
    360365       
    361366        if (root == NULL)
     
    368373        }
    369374       
    370         mutex_unlock(&sysinfo_lock);
     375        spinlock_unlock(&sysinfo_lock);
     376        interrupts_restore(ipl);
    371377}
    372378
     
    388394{
    389395        /* Protect sysinfo tree consistency */
    390         mutex_lock(&sysinfo_lock);
     396        ipl_t ipl = interrupts_disable();
     397        spinlock_lock(&sysinfo_lock);
    391398       
    392399        if (root == NULL)
     
    399406        }
    400407       
    401         mutex_unlock(&sysinfo_lock);
     408        spinlock_unlock(&sysinfo_lock);
     409        interrupts_restore(ipl);
    402410}
    403411
     
    412420{
    413421        /* Protect sysinfo tree consistency */
    414         mutex_lock(&sysinfo_lock);
     422        ipl_t ipl = interrupts_disable();
     423        spinlock_lock(&sysinfo_lock);
    415424       
    416425        if (root == NULL)
     
    421430                item->val_type = SYSINFO_VAL_UNDEFINED;
    422431       
    423         mutex_unlock(&sysinfo_lock);
     432        spinlock_unlock(&sysinfo_lock);
     433        interrupts_restore(ipl);
    424434}
    425435
     
    436446{
    437447        /* Protect sysinfo tree consistency */
    438         mutex_lock(&sysinfo_lock);
     448        ipl_t ipl = interrupts_disable();
     449        spinlock_lock(&sysinfo_lock);
    439450       
    440451        if (root == NULL)
     
    450461        }
    451462       
    452         mutex_unlock(&sysinfo_lock);
     463        spinlock_unlock(&sysinfo_lock);
     464        interrupts_restore(ipl);
    453465}
    454466
     
    467479/** Dump the structure of sysinfo tree
    468480 *
    469  * Should be called with sysinfo_lock held.
     481 * Should be called with interrupts disabled
     482 * and sysinfo_lock held. Because this routine
     483 * might take a reasonable long time to proceed,
     484 * having the spinlock held is not optimal, but
     485 * there is no better simple solution.
    470486 *
    471487 * @param root  Root item of the current (sub)tree.
     
    543559        /* Avoid other functions to mess with sysinfo
    544560           while we are dumping it */
    545         mutex_lock(&sysinfo_lock);
     561        ipl_t ipl = interrupts_disable();
     562        spinlock_lock(&sysinfo_lock);
    546563       
    547564        if (root == NULL)
     
    550567                sysinfo_dump_internal(root, 0);
    551568       
    552         mutex_unlock(&sysinfo_lock);
     569        spinlock_unlock(&sysinfo_lock);
     570        interrupts_restore(ipl);
    553571}
    554572
    555573/** Return sysinfo item value determined by name
    556574 *
    557  * Should be called with sysinfo_lock held.
     575 * Should be called with interrupts disabled
     576 * and sysinfo_lock held.
    558577 *
    559578 * @param name    Sysinfo path.
     
    640659                 * are reading it.
    641660                 */
    642                 mutex_lock(&sysinfo_lock);
     661                ipl_t ipl = interrupts_disable();
     662                spinlock_lock(&sysinfo_lock);
    643663                ret = sysinfo_get_item(path, NULL, dry_run);
    644                 mutex_unlock(&sysinfo_lock);
     664                spinlock_unlock(&sysinfo_lock);
     665                interrupts_restore(ipl);
    645666        }
    646667        free(path);
Note: See TracChangeset for help on using the changeset viewer.