root/include/linux/shm.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _LINUX_SHM_H_
   2 #define _LINUX_SHM_H_
   3 #include <linux/ipc.h>
   4 
   5 struct shmid_ds {
   6         struct ipc_perm shm_perm;       /* operation perms */
   7         int     shm_segsz;              /* size of segment (bytes) */
   8         time_t  shm_atime;              /* last attach time */
   9         time_t  shm_dtime;              /* last detach time */
  10         time_t  shm_ctime;              /* last change time */
  11         unsigned short  shm_cpid;       /* pid of creator */
  12         unsigned short  shm_lpid;       /* pid of last operator */
  13         short   shm_nattch;             /* no. of current attaches */
  14         /* the following are private */
  15         unsigned short   shm_npages;    /* size of segment (pages) */
  16         unsigned long   *shm_pages;     /* array of ptrs to frames -> SHMMAX */ 
  17         struct vm_area_struct *attaches; /* descriptors for attaches */
  18 };
  19 
  20 /* permission flag for shmget */
  21 #define SHM_R           0400    /* or S_IRUGO from <linux/stat.h> */
  22 #define SHM_W           0200    /* or S_IWUGO from <linux/stat.h> */
  23 
  24 /* mode for attach */
  25 #define SHM_RDONLY      010000  /* read-only access */
  26 #define SHM_RND         020000  /* round attach address to SHMLBA boundary */
  27 #define SHM_REMAP       040000  /* take-over region on attach */
  28 
  29 /* super user shmctl commands */
  30 #define SHM_LOCK        11
  31 #define SHM_UNLOCK      12
  32 
  33 struct  shminfo {
  34     int shmmax; 
  35     int shmmin; 
  36     int shmmni; 
  37     int shmseg; 
  38     int shmall; 
  39 };
  40 
  41 /* address range for shared memory attaches if no address passed to shmat() */
  42 #define SHM_RANGE_START 0x50000000
  43 #define SHM_RANGE_END   0x60000000
  44 
  45 /* format of page table entries that correspond to shared memory pages
  46    currently out in swap space (see also mm/swap.c):
  47    bit 0 (PAGE_PRESENT) is  = 0
  48    bits 7..1 (SWP_TYPE) are = SHM_SWP_TYPE
  49    bits 31..8 are used like this:
  50    bits 14..8 (SHM_ID) the id of the shared memory segment
  51    bits 29..15 (SHM_IDX) the index of the page within the shared memory segment
  52                     (actually only bits 24..15 get used since SHMMAX is so low)
  53 */
  54 
  55 #define SHM_ID_SHIFT    8
  56 /* Keep _SHM_ID_BITS as low as possible since SHMMNI depends on it and
  57    there is a static array of size SHMMNI. */
  58 #define _SHM_ID_BITS    7
  59 #define SHM_ID_MASK     ((1<<_SHM_ID_BITS)-1)
  60 
  61 #define SHM_IDX_SHIFT   (SHM_ID_SHIFT+_SHM_ID_BITS)
  62 #define _SHM_IDX_BITS   15
  63 #define SHM_IDX_MASK    ((1<<_SHM_IDX_BITS)-1)
  64 
  65 /* We must have SHM_ID_SHIFT + _SHM_ID_BITS + _SHM_IDX_BITS <= 32
  66    and SHMMAX <= (PAGE_SIZE << _SHM_IDX_BITS). */
  67 
  68 #define SHMMAX 0x3fa000                         /* max shared seg size (bytes) */
  69 #define SHMMIN 1         /* really PAGE_SIZE */ /* min shared seg size (bytes) */
  70 #define SHMMNI (1<<_SHM_ID_BITS)                /* max num of segs system wide */
  71 #define SHMALL (1<<(_SHM_IDX_BITS+_SHM_ID_BITS))/* max shm system wide (pages) */
  72 #define SHMLBA 0x1000                           /* attach addr a multiple of this */
  73 #define SHMSEG SHMMNI                           /* max shared segs per process */
  74 
  75 #ifdef __KERNEL__
  76 
  77 /* shm_mode upper byte flags */
  78 #define SHM_DEST        01000   /* segment will be destroyed on last detach */
  79 #define SHM_LOCKED      02000   /* segment will not be swapped */
  80 
  81 /* ipcs ctl commands */
  82 #define SHM_STAT        13
  83 #define SHM_INFO        14
  84 struct shm_info {
  85         int   used_ids;
  86         ulong shm_tot; /* total allocated shm */
  87         ulong shm_rss; /* total resident shm */
  88         ulong shm_swp; /* total swapped shm */
  89         ulong swap_attempts;
  90         ulong swap_successes;
  91 };
  92 
  93 #endif /* __KERNEL__ */
  94 
  95 #endif /* _LINUX_SHM_H_ */
  96 

/* [previous][next][first][last][top][bottom][index][help] */