]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/zalloc.c
xnu-344.tar.gz
[apple/xnu.git] / osfmk / kern / zalloc.c
index 0020560ea68d83fd75f765ef0246f05d79b27e2d..66e36c0160d98f71c7f4825a167329c8629fc17c 100644 (file)
@@ -224,14 +224,20 @@ vm_size_t zdata_size;
 
 #define lock_zone(zone)                                        \
 MACRO_BEGIN                                            \
-       simple_lock(&zone->lock);                       \
+       simple_lock(&(zone)->lock);                     \
 MACRO_END
 
 #define unlock_zone(zone)                              \
 MACRO_BEGIN                                            \
-       simple_unlock(&zone->lock);                     \
+       simple_unlock(&(zone)->lock);                   \
 MACRO_END
 
+#define zone_wakeup(zone) thread_wakeup((event_t)(zone))
+#define zone_sleep(zone)                               \
+       thread_sleep_simple_lock((event_t)(zone),       \
+                               &(zone)->lock,          \
+                               THREAD_UNINT)
+
 #define lock_zone_init(zone)                           \
 MACRO_BEGIN                                            \
        simple_lock_init(&zone->lock, ETAP_MISC_ZONE);  \
@@ -624,11 +630,8 @@ zalloc_canblock(
                         *      Someone is allocating memory for this zone.
                         *      Wait for it to show up, then try again.
                         */
-                       assert_wait((event_t)zone, THREAD_UNINT);
                        zone->waiting = TRUE;
-                       unlock_zone(zone);
-                       thread_block((void (*)(void)) 0);
-                       lock_zone(zone);
+                       zone_sleep(zone);
                }
                else {
                        if ((zone->cur_size + zone->elem_size) >
@@ -682,7 +685,7 @@ zalloc_canblock(
                                zone->doing_alloc = FALSE; 
                                if (zone->waiting) {
                                        zone->waiting = FALSE;
-                                       thread_wakeup((event_t)zone);
+                                       zone_wakeup(zone);
                                }
                                REMOVE_FROM_ZONE(zone, addr, vm_offset_t);
                                if (addr == 0 &&