Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/frame.c

    r6188fee rc626117  
    6363#include <proc/thread.h> /* THREAD */
    6464
    65 zones_t zones;
     65zones_t zones = {
     66        .count = 0,
     67        .lock = IRQ_SPINLOCK_INITIALIZER("frame.zones.lock"),
     68};
    6669
    6770/*
     
    6972 * available.
    7073 */
    71 static mutex_t mem_avail_mtx;
    72 static condvar_t mem_avail_cv;
     74static IRQ_SPINLOCK_INITIALIZE(mem_avail_lock);
     75static CONDVAR_INITIALIZE(mem_avail_cv);
    7376static size_t mem_avail_req = 0;  /**< Number of frames requested. */
    7477static size_t mem_avail_gen = 0;  /**< Generation counter. */
     
    948951#endif
    949952
    950                 /*
    951                  * Since the mem_avail_mtx is an active mutex, we need to
    952                  * disable interrupts to prevent deadlock with TLB shootdown.
    953                  */
    954                 ipl_t ipl = interrupts_disable();
    955                 mutex_lock(&mem_avail_mtx);
     953                /* Disabled interrupts needed to prevent deadlock with TLB shootdown. */
     954                irq_spinlock_lock(&mem_avail_lock, true);
    956955
    957956                if (mem_avail_req > 0)
     
    963962
    964963                while (gen == mem_avail_gen)
    965                         condvar_wait(&mem_avail_cv, &mem_avail_mtx);
    966 
    967                 mutex_unlock(&mem_avail_mtx);
    968                 interrupts_restore(ipl);
     964                        condvar_wait(&mem_avail_cv, &mem_avail_lock);
     965
     966                irq_spinlock_unlock(&mem_avail_lock, true);
    969967
    970968#ifdef CONFIG_DEBUG
     
    10241022        irq_spinlock_unlock(&zones.lock, true);
    10251023
    1026         /*
    1027          * Signal that some memory has been freed.
    1028          * Since the mem_avail_mtx is an active mutex,
    1029          * we need to disable interruptsto prevent deadlock
    1030          * with TLB shootdown.
    1031          */
    1032 
    1033         ipl_t ipl = interrupts_disable();
    1034         mutex_lock(&mem_avail_mtx);
     1024        /* Signal that some memory has been freed. */
     1025
     1026        /* Disabled interrupts needed to prevent deadlock with TLB shootdown. */
     1027        irq_spinlock_lock(&mem_avail_lock, true);
    10351028
    10361029        if (mem_avail_req > 0)
     
    10421035        }
    10431036
    1044         mutex_unlock(&mem_avail_mtx);
    1045         interrupts_restore(ipl);
     1037        irq_spinlock_unlock(&mem_avail_lock, true);
    10461038
    10471039        if (!(flags & FRAME_NO_RESERVE))
     
    11081100void frame_init(void)
    11091101{
    1110         if (config.cpu_active == 1) {
    1111                 zones.count = 0;
    1112                 irq_spinlock_initialize(&zones.lock, "frame.zones.lock");
    1113                 mutex_initialize(&mem_avail_mtx, MUTEX_ACTIVE);
    1114                 condvar_initialize(&mem_avail_cv);
    1115         }
    1116 
    11171102        /* Tell the architecture to create some memory */
    11181103        frame_low_arch_init();
Note: See TracChangeset for help on using the changeset viewer.