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 shm_desc *attaches;    /* descriptors for attaches */
  18 };
  19 
  20 /* mode for attach */
  21 #define SHM_RDONLY      010000  /* read-only access */
  22 #define SHM_RND         020000  /* round attach address to SHMLBA boundary */
  23 #define SHM_REMAP       040000  /* take-over region on attach */
  24 
  25 /* super user shmctl commands */
  26 #define SHM_LOCK        11
  27 #define SHM_UNLOCK      12
  28 
  29 struct  shminfo {
  30     int shmmax; 
  31     int shmmin; 
  32     int shmmni; 
  33     int shmseg; 
  34     int shmall; 
  35 };
  36 
  37 #define SHMMAX 0x400000  /* <= 4M */          /* max shared seg size (bytes) */
  38 #define SHMMIN 1         /* really PAGE_SIZE */  /* min shared seg size (bytes)*/
  39 #define SHMMNI 128       /* <= 4096 */        /* max num of segs system wide */
  40 #define SHMALL 0x10000 /* <= SHMMAX*SHMMNI/PAGE_SIZE */  /* max shm system wide (pages) */
  41 #define SHMLBA 0x1000    /* = PAGE_SIZE */   /*  attach addr multiple */
  42 #define SHMSEG SHMMNI    /* <= SHMMNI */    /* max shared segs per process */
  43 
  44 
  45 #ifdef __KERNEL__
  46 
  47 /* shm_mode upper byte flags */
  48 #define SHM_DEST        01000   /* segment will be destroyed on last detach */
  49 #define SHM_LOCKED      02000   /* segment will not be swapped */
  50 
  51 /* ipcs ctl commands */
  52 #define SHM_STAT        13
  53 #define SHM_INFO        14
  54 struct shm_info {
  55         int   used_ids;
  56         ulong shm_tot; /* total allocated shm */
  57         ulong shm_rss; /* total resident shm */
  58         ulong shm_swp; /* total swapped shm */
  59         ulong swap_attempts;
  60         ulong swap_successes;
  61 };
  62 
  63 
  64 /*
  65  * Per process internal structure for managing segments.
  66  * A shmat will add to and shmdt will remove from the list.
  67  */
  68 struct  shm_desc {
  69         struct task_struct *task;     /* attacher */
  70         unsigned long shm_sgn;        /* signature for this attach */
  71         unsigned long start;   /* virt addr of attach, multiple of SHMLBA */
  72         unsigned long end;            /* multiple of SHMLBA */
  73         struct shm_desc *task_next;   /* next attach for task */
  74         struct shm_desc *seg_next;    /* next attach for segment */
  75 };
  76 
  77 /* not present page table entry format bit 0 is 0, high byte defined in mm.h */
  78 #define SHM_IDX_SHIFT 20
  79 #define SHM_IDX_MASK  0x3FF
  80 #define SHM_ID_SHIFT  8
  81 #define SHM_ID_MASK   0xFFF
  82 #define SHM_READ_ONLY 0x80000000
  83 
  84 #endif /* __KERNEL__ */
  85 
  86 #endif /* _LINUX_SHM_H_ */
  87 
  88 

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