-/* $OpenBSD: vm_object.c,v 1.12 1996/11/06 23:24:40 niklas Exp $ */
+/* $OpenBSD: vm_object.c,v 1.13 1996/12/24 20:14:28 niklas Exp $ */
/* $NetBSD: vm_object.c,v 1.34 1996/02/28 22:35:35 gwr Exp $ */
/*
register vm_page_t p;
vm_object_t shadow_object;
+ /*
+ * Setters of paging_in_progress might be interested that this object
+ * is going away as soon as we get a grip on it.
+ */
+ object->flags |= OBJ_FADING;
+
+ /*
+ * Wait until the pageout daemon is through with the object or a
+ * potential collapse operation is finished.
+ */
+ while (object->paging_in_progress) {
+ vm_object_sleep(object, object, FALSE);
+ vm_object_lock(object);
+ }
+
/*
* Detach the object from its shadow if we are the shadow's
* copy.
vm_object_unlock(shadow_object);
}
- /*
- * Wait until the pageout daemon is through with the object.
- */
- while (object->paging_in_progress) {
- vm_object_sleep(object, object, FALSE);
- vm_object_lock(object);
- }
-
/*
* If not an internal object clean all the pages, removing them
* from paging queues as we go.
thread_wakeup(backing_object);
thread_wakeup(object);
+ /*
+ * During the pagein vm_object_terminate
+ * might have slept on our front object in
+ * order to remove it. If this is the
+ * case, we might as well stop all the
+ * collapse work right here.
+ */
+ if (object->flags & OBJ_FADING) {
+ PAGE_WAKEUP(backing_page);
+ return KERN_FAILURE;
+ }
+
/*
* Third, relookup in case pager changed
* page. Pager is responsible for
-/* $OpenBSD: vm_object.h,v 1.3 1996/08/02 00:06:02 niklas Exp $ */
+/* $OpenBSD: vm_object.h,v 1.4 1996/12/24 20:14:32 niklas Exp $ */
/* $NetBSD: vm_object.h,v 1.16 1995/03/29 22:10:28 briggs Exp $ */
/*
#define OBJ_CANPERSIST 0x0001 /* allow to persist */
#define OBJ_INTERNAL 0x0002 /* internally created object */
#define OBJ_ACTIVE 0x0004 /* used to mark active objects */
+#define OBJ_FADING 0x0008 /* tell others that the object is going away */
TAILQ_HEAD(vm_object_hash_head, vm_object_hash_entry);