Changeset c2ab3f4 in mainline for kernel/generic/src/sysinfo/sysinfo.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/sysinfo.c

    rb8f7ea78 rc2ab3f4  
    3737#include <print.h>
    3838#include <syscall/copy.h>
    39 #include <synch/spinlock.h>
     39#include <synch/mutex.h>
    4040#include <arch/asm.h>
    4141#include <errno.h>
     
    5252static slab_cache_t *sysinfo_item_slab;
    5353
    54 /** Sysinfo spinlock */
    55 SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");
     54/** Sysinfo lock */
     55static mutex_t 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);
    100102}
    101103
    102104/** Recursively find an item in sysinfo tree
    103105 *
    104  * Should be called with interrupts disabled
    105  * and sysinfo_lock held.
     106 * Should be called with sysinfo_lock held.
    106107 *
    107108 * @param name    Current sysinfo path suffix.
     
    168169/** Recursively create items in sysinfo tree
    169170 *
    170  * Should be called with interrupts disabled
    171  * and sysinfo_lock held.
     171 * Should be called with sysinfo_lock held.
    172172 *
    173173 * @param name     Current sysinfo path suffix.
     
    299299{
    300300        /* Protect sysinfo tree consistency */
    301         ipl_t ipl = interrupts_disable();
    302         spinlock_lock(&sysinfo_lock);
     301        mutex_lock(&sysinfo_lock);
    303302       
    304303        if (root == NULL)
     
    311310        }
    312311       
    313         spinlock_unlock(&sysinfo_lock);
    314         interrupts_restore(ipl);
     312        mutex_unlock(&sysinfo_lock);
    315313}
    316314
     
    332330{
    333331        /* Protect sysinfo tree consistency */
    334         ipl_t ipl = interrupts_disable();
    335         spinlock_lock(&sysinfo_lock);
     332        mutex_lock(&sysinfo_lock);
    336333       
    337334        if (root == NULL)
     
    345342        }
    346343       
    347         spinlock_unlock(&sysinfo_lock);
    348         interrupts_restore(ipl);
     344        mutex_unlock(&sysinfo_lock);
    349345}
    350346
     
    361357{
    362358        /* Protect sysinfo tree consistency */
    363         ipl_t ipl = interrupts_disable();
    364         spinlock_lock(&sysinfo_lock);
     359        mutex_lock(&sysinfo_lock);
    365360       
    366361        if (root == NULL)
     
    373368        }
    374369       
    375         spinlock_unlock(&sysinfo_lock);
    376         interrupts_restore(ipl);
     370        mutex_unlock(&sysinfo_lock);
    377371}
    378372
     
    394388{
    395389        /* Protect sysinfo tree consistency */
    396         ipl_t ipl = interrupts_disable();
    397         spinlock_lock(&sysinfo_lock);
     390        mutex_lock(&sysinfo_lock);
    398391       
    399392        if (root == NULL)
     
    406399        }
    407400       
    408         spinlock_unlock(&sysinfo_lock);
    409         interrupts_restore(ipl);
     401        mutex_unlock(&sysinfo_lock);
    410402}
    411403
     
    420412{
    421413        /* Protect sysinfo tree consistency */
    422         ipl_t ipl = interrupts_disable();
    423         spinlock_lock(&sysinfo_lock);
     414        mutex_lock(&sysinfo_lock);
    424415       
    425416        if (root == NULL)
     
    430421                item->val_type = SYSINFO_VAL_UNDEFINED;
    431422       
    432         spinlock_unlock(&sysinfo_lock);
    433         interrupts_restore(ipl);
     423        mutex_unlock(&sysinfo_lock);
    434424}
    435425
     
    446436{
    447437        /* Protect sysinfo tree consistency */
    448         ipl_t ipl = interrupts_disable();
    449         spinlock_lock(&sysinfo_lock);
     438        mutex_lock(&sysinfo_lock);
    450439       
    451440        if (root == NULL)
     
    461450        }
    462451       
    463         spinlock_unlock(&sysinfo_lock);
    464         interrupts_restore(ipl);
     452        mutex_unlock(&sysinfo_lock);
    465453}
    466454
     
    479467/** Dump the structure of sysinfo tree
    480468 *
    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.
     469 * Should be called with sysinfo_lock held.
    486470 *
    487471 * @param root  Root item of the current (sub)tree.
     
    559543        /* Avoid other functions to mess with sysinfo
    560544           while we are dumping it */
    561         ipl_t ipl = interrupts_disable();
    562         spinlock_lock(&sysinfo_lock);
     545        mutex_lock(&sysinfo_lock);
    563546       
    564547        if (root == NULL)
     
    567550                sysinfo_dump_internal(root, 0);
    568551       
    569         spinlock_unlock(&sysinfo_lock);
    570         interrupts_restore(ipl);
     552        mutex_unlock(&sysinfo_lock);
    571553}
    572554
    573555/** Return sysinfo item value determined by name
    574556 *
    575  * Should be called with interrupts disabled
    576  * and sysinfo_lock held.
     557 * Should be called with sysinfo_lock held.
    577558 *
    578559 * @param name    Sysinfo path.
     
    659640                 * are reading it.
    660641                 */
    661                 ipl_t ipl = interrupts_disable();
    662                 spinlock_lock(&sysinfo_lock);
     642                mutex_lock(&sysinfo_lock);
    663643                ret = sysinfo_get_item(path, NULL, dry_run);
    664                 spinlock_unlock(&sysinfo_lock);
    665                 interrupts_restore(ipl);
     644                mutex_unlock(&sysinfo_lock);
    666645        }
    667646        free(path);
Note: See TracChangeset for help on using the changeset viewer.