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