home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / sys / h / shm < prev    next >
Encoding:
Text File  |  1995-01-11  |  3.4 KB  |  119 lines

  1. /*
  2.  * $Header: /ax/networking:include/sys/shm.h:networking  1.1  $
  3.  * $Source: /ax/networking:include/sys/shm.h: $
  4.  *
  5.  * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
  6.  *
  7.  * $Log:    shm.h,v $
  8.  * Revision 1.1  95/01/11  10:19:44  kwelton
  9.  * Initial revision
  10.  * 
  11.  * Revision 1.3  88/06/17  20:20:58  beta
  12.  * Acorn Unix initial beta version
  13.  * 
  14.  */
  15. /*
  16. **    IPC Shared Memory Facility.
  17. */
  18.  
  19. #ifndef _SHM_
  20. #define _SHM_
  21.  
  22. /*
  23. **    Implementation Constants and system limits.
  24. */
  25.  
  26. #define    SHMLBA        NBPG    /* segment low boundary address multiple    */
  27.                 /* (SHMLBA must be a multiple of page size) */
  28.  
  29. #define NSHMID        (10)    /* Max shared memory segs in system */
  30. #define NSHMAT        (5)    /* Max segs attached to one process */
  31. #define NSHMVPAGES    (32)    /* Amount of virtual address space  */
  32.                 /* reserved for shm in each process */
  33. #define SHMMINPAGES    (1)    /* Min shared region size */
  34. #define SHMMAXPAGES    (8)    /* Max shared region size */
  35. #define SHMTOTPAGES    (16)    /* Limit on total system shm size  */
  36.  
  37. /*
  38. **    Permission Definitions.
  39. */
  40.  
  41. #define    SHM_R    0400    /* read permission */
  42. #define    SHM_W    0200    /* write permission */
  43.  
  44. /*
  45. **    ipc_perm Mode Definitions.
  46. */
  47.  
  48. #define    SHM_INIT    01000    /* grow segment on next attach */
  49. #define    SHM_DEST    02000    /* destroy segment when # attached = 0 */
  50.  
  51. /*
  52. **    Message Operation Flags.
  53. */
  54.  
  55. #define    SHM_RDONLY    010000    /* attach read-only (else read-write) */
  56. #define    SHM_RND        020000    /* round attach address to SHMLBA */
  57.  
  58. /*
  59. **    Structure Definitions.
  60. */
  61.  
  62. /*
  63. **    There is a shared mem id data structure for each segment in the system.
  64. */
  65.  
  66. struct shmid_ds {
  67.     struct ipc_perm    shm_perm;    /* operation permission struct */
  68.     int        shm_segsz;    /* size of segment in bytes */
  69.     ushort        shm_lpid;    /* pid of last shmop */
  70.     ushort        shm_cpid;    /* pid of creator */
  71.     time_t        shm_atime;    /* last shmat time */
  72.     time_t        shm_dtime;    /* last shmdt time */
  73.     time_t        shm_ctime;    /* last change time */
  74.     short        shm_nattch;    /* number of current attachments */
  75.     struct shmat_ds *shm_shmat;    /* linked list of attachments */
  76. #ifdef KERNEL
  77.     struct region    *shm_reg;    /* ptr to region structure */
  78. #else KERNEL
  79.     char            *shm_reg;    /* so user progs don't need region.h */
  80. #endif KERNEL
  81. };
  82.  
  83. /*
  84.  * There is a shmat_ds for each instance of a shared region being 
  85.  * attached to a process's address space.
  86.  */
  87.  
  88. struct shmat_ds
  89. {
  90.   struct shmid_ds *sa_shm;       /* Pointer to shared memory table entry     */
  91.                                  /* (0 if this shmat_ds is not in use)       */
  92.   struct shmat_ds *sa_link;     /* Link to other attachments of this seg    */
  93. #ifdef KERNEL
  94.   struct proc     *sa_proc;      /* Process to which attached                */
  95. #else KERNEL
  96.   char          *sa_proc;     /* so user progs don't need proc.h          */
  97. #endif KERNEL
  98.   caddr_t         sa_baseaddr;   /* Where segment mapped in proc addr space  */
  99.   int             sa_access;     /* Access allowed to segment (SHM_R always, */
  100.                  /* SHM_W optional).                         */
  101. };
  102.  
  103.  
  104. /* The rest is for the kernel only */
  105.  
  106. #ifdef KERNEL
  107. extern char *shm_base;  /* Lowest virtual address available for mapping      */
  108.                         /* shared memory segments. There are SHMVPAGES       */
  109.                         /* available starting here.                          */
  110. extern char *shm_limit; /* Points just after highest virtual address         */
  111.                         /* reserved for mapping shared memory.               */
  112.  
  113. extern struct pte *shm_vtopte(); /* Find pte for given shm virtual page no. */
  114. #endif KERNEL
  115.  
  116. #endif _SHM_
  117.  
  118. /* EOF shm.h */
  119.