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 SHM_RANGE_START 0x40000000
  38 #define SHM_RANGE_END   0x60000000
  39 
  40                                 /* _SHM_ID_BITS is a variable you can adjust to */
  41                                 /* tune the kernel.  It determines the value of */
  42                                 /* SHMMNI, which specifies the maximum no. of */
  43                                 /* shared segments (system wide).  SRB. */
  44 #define _SHM_ID_BITS    7               /* keep as low as possible */
  45                                         /* a static array is declared */
  46                                         /* using SHMMNI */
  47 
  48 #define __SHM_IDX_BITS  (BITS_PER_PTR-2-SHM_IDX_SHIFT)
  49 
  50 /* !!!!!!!?????
  51  * Why reserve the two (2) high bits of the signature (shm_sgn) field?
  52  * Since, as far as I can see, only the high bit is used (SHM_READ_ONLY).
  53  *                                              SRB.
  54  */
  55 
  56 #define _SHM_IDX_BITS   (__SHM_IDX_BITS+PAGE_SHIFT>=BITS_PER_PTR?\
  57  BITS_PER_PTR-PAGE_SHIFT-1:__SHM_IDX_BITS)      /* sanity check */
  58 
  59 /* not present page table entry format bit 0 is 0, low byte defined in mm.h */
  60 #define SHM_ID_SHIFT    8
  61 #define SHM_ID_MASK     ((1<<_SHM_ID_BITS)-1)
  62 #define SHM_IDX_SHIFT   (SHM_ID_SHIFT+_SHM_ID_BITS)
  63 #define SHM_IDX_MASK    ((1<<_SHM_IDX_BITS)-1)
  64 #define SHM_READ_ONLY   (1<<(BITS_PER_PTR-1))
  65 
  66 #define SHMMAX 0x3fa000                         /* max shared seg size (bytes) */
  67 #define SHMMIN 1         /* really PAGE_SIZE */ /* min shared seg size (bytes) */
  68 #define SHMMNI (1<<_SHM_ID_BITS)                /* max num of segs system wide */
  69 #define SHMALL (1<<(_SHM_IDX_BITS+_SHM_ID_BITS))/* max shm system wide (pages) */
  70 #define SHMLBA 0x1000                           /* attach addr a multiple of this */
  71 #define SHMSEG SHMMNI                           /* max shared segs per process */
  72 
  73 #ifdef __KERNEL__
  74 
  75 /* shm_mode upper byte flags */
  76 #define SHM_DEST        01000   /* segment will be destroyed on last detach */
  77 #define SHM_LOCKED      02000   /* segment will not be swapped */
  78 
  79 /* ipcs ctl commands */
  80 #define SHM_STAT        13
  81 #define SHM_INFO        14
  82 struct shm_info {
  83         int   used_ids;
  84         ulong shm_tot; /* total allocated shm */
  85         ulong shm_rss; /* total resident shm */
  86         ulong shm_swp; /* total swapped shm */
  87         ulong swap_attempts;
  88         ulong swap_successes;
  89 };
  90 
  91 
  92 /*
  93  * Per process internal structure for managing segments.
  94  * A shmat will add to and shmdt will remove from the list.
  95  */
  96 struct  shm_desc {
  97         struct task_struct *task;     /* attacher */
  98         unsigned long shm_sgn;        /* signature for this attach */
  99         unsigned long start;   /* virt addr of attach, multiple of SHMLBA */
 100         unsigned long end;            /* multiple of SHMLBA */
 101         struct shm_desc *task_next;   /* next attach for task */
 102         struct shm_desc *seg_next;    /* next attach for segment */
 103 };
 104 
 105 #endif /* __KERNEL__ */
 106 
 107 #endif /* _LINUX_SHM_H_ */
 108 
 109 

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