Changes in kernel/generic/src/mm/frame.c [6188fee:c626117] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r6188fee rc626117 63 63 #include <proc/thread.h> /* THREAD */ 64 64 65 zones_t zones; 65 zones_t zones = { 66 .count = 0, 67 .lock = IRQ_SPINLOCK_INITIALIZER("frame.zones.lock"), 68 }; 66 69 67 70 /* … … 69 72 * available. 70 73 */ 71 static mutex_t mem_avail_mtx;72 static condvar_t mem_avail_cv;74 static IRQ_SPINLOCK_INITIALIZE(mem_avail_lock); 75 static CONDVAR_INITIALIZE(mem_avail_cv); 73 76 static size_t mem_avail_req = 0; /**< Number of frames requested. */ 74 77 static size_t mem_avail_gen = 0; /**< Generation counter. */ … … 948 951 #endif 949 952 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); 956 955 957 956 if (mem_avail_req > 0) … … 963 962 964 963 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); 969 967 970 968 #ifdef CONFIG_DEBUG … … 1024 1022 irq_spinlock_unlock(&zones.lock, true); 1025 1023 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); 1035 1028 1036 1029 if (mem_avail_req > 0) … … 1042 1035 } 1043 1036 1044 mutex_unlock(&mem_avail_mtx); 1045 interrupts_restore(ipl); 1037 irq_spinlock_unlock(&mem_avail_lock, true); 1046 1038 1047 1039 if (!(flags & FRAME_NO_RESERVE)) … … 1108 1100 void frame_init(void) 1109 1101 { 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 1117 1102 /* Tell the architecture to create some memory */ 1118 1103 frame_low_arch_init();
Note:
See TracChangeset
for help on using the changeset viewer.