vm_pageout.h revision 1549
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1991, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * This code is derived from software contributed to Berkeley by
61541Srgrimes * The Mach Operating System project at Carnegie-Mellon University.
71541Srgrimes *
81541Srgrimes * Redistribution and use in source and binary forms, with or without
91541Srgrimes * modification, are permitted provided that the following conditions
101541Srgrimes * are met:
111541Srgrimes * 1. Redistributions of source code must retain the above copyright
121541Srgrimes *    notice, this list of conditions and the following disclaimer.
131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer in the
151541Srgrimes *    documentation and/or other materials provided with the distribution.
161541Srgrimes * 3. All advertising materials mentioning features or use of this software
171541Srgrimes *    must display the following acknowledgement:
181541Srgrimes *	This product includes software developed by the University of
191541Srgrimes *	California, Berkeley and its contributors.
201541Srgrimes * 4. Neither the name of the University nor the names of its contributors
211541Srgrimes *    may be used to endorse or promote products derived from this software
221541Srgrimes *    without specific prior written permission.
231541Srgrimes *
241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341541Srgrimes * SUCH DAMAGE.
351541Srgrimes *
361541Srgrimes *	@(#)vm_pageout.h	8.2 (Berkeley) 1/12/94
371541Srgrimes *
381541Srgrimes *
391541Srgrimes * Copyright (c) 1987, 1990 Carnegie-Mellon University.
401541Srgrimes * All rights reserved.
411541Srgrimes *
421541Srgrimes * Author: Avadis Tevanian, Jr.
431541Srgrimes *
441541Srgrimes * Permission to use, copy, modify and distribute this software and
451541Srgrimes * its documentation is hereby granted, provided that both the copyright
461541Srgrimes * notice and this permission notice appear in all copies of the
471541Srgrimes * software, derivative works or modified versions, and any portions
481541Srgrimes * thereof, and that both notices appear in supporting documentation.
491541Srgrimes *
501541Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
511541Srgrimes * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
521541Srgrimes * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
531541Srgrimes *
541541Srgrimes * Carnegie Mellon requests users of this software to return to
551541Srgrimes *
561541Srgrimes *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
571541Srgrimes *  School of Computer Science
581541Srgrimes *  Carnegie Mellon University
591541Srgrimes *  Pittsburgh PA 15213-3890
601541Srgrimes *
611541Srgrimes * any improvements or extensions that they make and grant Carnegie the
621541Srgrimes * rights to redistribute these changes.
631541Srgrimes */
641541Srgrimes
651541Srgrimes/*
661541Srgrimes *	Header file for pageout daemon.
671541Srgrimes */
681541Srgrimes
691541Srgrimes/*
701541Srgrimes *	Exported data structures.
711541Srgrimes */
721541Srgrimes
731541Srgrimesextern int	vm_pages_needed;	/* should be some "event" structure */
741541Srgrimessimple_lock_data_t	vm_pages_needed_lock;
751549Srgrimesextern int vm_pageout_pages_needed;
761541Srgrimes
771549Srgrimes#define VM_PAGEOUT_ASYNC 0
781549Srgrimes#define VM_PAGEOUT_SYNC 1
791549Srgrimes#define VM_PAGEOUT_FORCE 2
801541Srgrimes
811541Srgrimes/*
821541Srgrimes *	Exported routines.
831541Srgrimes */
841541Srgrimes
851541Srgrimes/*
861541Srgrimes *	Signal pageout-daemon and wait for it.
871541Srgrimes */
881541Srgrimes
891549Srgrimes#define VM_WAIT vm_wait()
901549Srgrimes
911549Srgrimesinline static void vm_wait() {
921549Srgrimes	extern struct proc *curproc, *pageproc;
931549Srgrimes	int s;
941549Srgrimes	s = splhigh();
951549Srgrimes	if (curproc == pageproc) {
961549Srgrimes		vm_pageout_pages_needed = 1;
971549Srgrimes		tsleep((caddr_t) &vm_pageout_pages_needed, PSWP, "vmwait", 0);
981549Srgrimes		vm_pageout_pages_needed = 0;
991549Srgrimes	} else {
1001549Srgrimes		wakeup((caddr_t) &vm_pages_needed);
1011549Srgrimes		tsleep((caddr_t) &cnt.v_free_count, PVM, "vmwait", 0);
1021549Srgrimes	}
1031549Srgrimes	splx(s);
1041549Srgrimes}
1051549Srgrimes
1061549Srgrimes
1071541Srgrimes#ifdef KERNEL
1081541Srgrimesvoid		 vm_pageout __P((void));
1091549Srgrimesint		 vm_pageout_scan __P((void));
1101541Srgrimesvoid		 vm_pageout_page __P((vm_page_t, vm_object_t));
1111541Srgrimesvoid		 vm_pageout_cluster __P((vm_page_t, vm_object_t));
1121541Srgrimes#endif
113