home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / vm / anon.h next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  3.3 KB  |  120 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. /*
  11.  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12.  *         PROPRIETARY NOTICE (Combined)
  13.  * 
  14.  * This source code is unpublished proprietary information
  15.  * constituting, or derived under license from AT&T's UNIX(r) System V.
  16.  * In addition, portions of such source code were derived from Berkeley
  17.  * 4.3 BSD under license from the Regents of the University of
  18.  * California.
  19.  * 
  20.  * 
  21.  * 
  22.  *         Copyright Notice 
  23.  * 
  24.  * Notice of copyright on this source code product does not indicate 
  25.  * publication.
  26.  * 
  27.  *     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  28.  *     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  29.  *               All rights reserved.
  30.  *  
  31.  */
  32.  
  33. #ifndef _VM_ANON_H
  34. #define _VM_ANON_H
  35.  
  36. #ident    "@(#)/usr/include/vm/anon.h.sl 1.1 4.0 12/08/90 14832 AT&T-USL"
  37.  
  38. /*
  39.  * VM - Anonymous pages.
  40.  */
  41.  
  42. /*
  43.  * Each page which is anonymous, either in memory or in swap,
  44.  * has an anon structure.  The structure's primary purpose is
  45.  * to hold a reference count so that we can detect when the last
  46.  * copy of a multiply-referenced copy-on-write page goes away.
  47.  * When on the free list, un.next gives the next anon structure
  48.  * in the list.  Otherwise, un.page is a ``hint'' which probably
  49.  * points to the current page.  This must be explicitly checked
  50.  * since the page can be moved underneath us.  This is simply
  51.  * an optimization to avoid having to look up each page when
  52.  * doing things like fork.
  53.  */
  54. struct anon {
  55.     int    an_refcnt;
  56.     union {
  57.         struct    page *an_page;    /* ``hint'' to the real page */
  58.         struct    anon *an_next;    /* free list pointer */
  59.     } un;
  60.     struct anon *an_bap;        /* pointer to real anon */
  61.     short    an_flag;        /* see below */
  62.     short    an_use;            /* for debugging code */
  63. };
  64.  
  65. /* an_flag values */
  66. #define ALOCKED    0x1
  67. #define AWANT    0x2
  68.  
  69. #ifdef DEBUG
  70. /* an_use values */
  71. #define AN_NONE        0
  72. #define AN_DATA        1
  73. #define AN_UPAGE    2
  74. #endif
  75.  
  76. struct anoninfo {
  77.     u_int    ani_max;    /* maximum anon pages available */
  78.     u_int    ani_free;    /* number of anon pages currently free */
  79.     u_int    ani_resv;    /* number of anon pages reserved */
  80. };
  81.  
  82. #ifdef _KERNEL
  83. extern    struct anoninfo anoninfo;
  84.  
  85. struct    anon *anon_alloc();
  86. void    anon_dup(/* old, new, size */);
  87. void    anon_free(/* app, size */);
  88. int    anon_getpage(/* app, protp, pl, sz, seg, addr, rw, cred */);
  89. struct    page *anon_private(/* app, seg, addr, ppsteal */);
  90. struct    page *anon_zero(/* seg, addr, app */);
  91. struct    page *anon_zero_aligned(/* seg, addr, app, align_mask, align_val */);
  92. void    anon_unloadmap(/* ap, ref, mod */);
  93. int    anon_resv(/* size */);
  94. void    anon_unresv(/* size */);
  95.  
  96. #define ALOCK(ap) { \
  97.     while ((ap)->an_flag & ALOCKED) { \
  98.         (ap)->an_flag |= AWANT; \
  99.         (void) sleep((caddr_t)(ap), PINOD); \
  100.     } \
  101.     (ap)->an_flag |= ALOCKED; \
  102. }
  103.  
  104. #define AUNLOCK(ap) { \
  105.     ASSERT((ap)->an_flag & ALOCKED); \
  106.     (ap)->an_flag &= ~ALOCKED; \
  107.     if ((ap)->an_flag & AWANT) { \
  108.         (ap)->an_flag &= ~AWANT; \
  109.         wakeprocs((caddr_t)(ap), PRMPT); \
  110.     } \
  111. }
  112.  
  113. /* flags to anon_private */
  114. #define STEAL_PAGE 0x1
  115. #define LOCK_PAGE 0x2
  116.  
  117. #endif /* _KERNEL */
  118.  
  119. #endif    /* _VM_ANON_H */
  120.