____cacheline_aligned_in_smp 14 sem_perm; /* permissions .. see ipc.h */ 15 time_t sem_ctime; /* last change time */ 16 struct sem *sem_base; /* ptr to first semaphore in array */ 17 struct list_head pending_alter; /* pending operations */ 18 /* that alter the array */ 19 struct list_head pending_const; /* pending complex operations */ 20 /* that do not alter semvals */ 21 struct list_head list_id; /* undo requests on this array */ 22 int sem_nsems; /* no. of semaphores in array */ 23 int complex_count; /* pending complex operations */ 24 };
q_perm; 20 time_t q_stime; /* last msgsnd time */ 21 time_t q_rtime; /* last msgrcv time */ 22 time_t q_ctime; /* last change time */ 23 unsigned long q_cbytes; /* current number of bytes on queue */ 24 unsigned long q_qnum; /* number of messages in queue */ 25 unsigned long q_qbytes; /* max number of bytes on queue */ 26 pid_t q_lspid; /* pid of last msgsnd */ 27 pid_t q_lrpid; /* last receive pid */ 28 29 struct list_head q_messages; 30 struct list_head q_receivers; 31 struct list_head q_senders; 32 };
ipc_namespace *, struct ipc_params *); 82 int (*associate)(struct kern_ipc_perm *, int); 83 int (*more_checks)(struct kern_ipc_perm *, struct ipc_params *); 84 }; w HFUOFX w ৽نʹ*1$ͷΦϒδΣΫτΛ࡞ w BTTPDJBUF w ύʔϛογϣϯͷνΣοΫ w NPSF@DIFDLT w ͦͷଞͷνΣοΫ w PQUJPOBM
--> ipcget_public() // if key is not IPC_PRIVATE --> ipc_findkey() // find key --> ipcget_new() // if key is not found --> ipc_check_perms() // if found key --> (struct ips_ops *)->more_checks() --> (struct ips_ops *)->associate() ipcget_new() --> (struct ipc_ops *)->getnew()
w *1$ͷཧΦϒδΣΫτTUSVDUTINJE@LFSOFM w ࡞ͨ͠ΦϒδΣΫτDVSSFOUTZTWTINTIN@DMJTUʹͭͳ͕Δ w ηάϝϯτٖࣅϑΝΠϧͱͯ͠࡞Δ w 4:47YYYYYYYY YLFZ ͱ͍͏ϑΝΠϧ໊ w MTPG͢ΔͱҎԼͷΑ͏ʹදࣔ͞ΕΔ 41997 a.out 29678 root DEL REG 0,4 27394068 /SYSV00000000 w qBHʹ4).@)6(&5-#ʹΑΓϑΝΠϧͷ࡞ํ๏͕มΘΔ w IVHFUMC@pMF@TFUVQ PSTINFN@pMF@TFUVQ
mntget() // path to mount directory --> d_alloc_pseudo() // allocate a dentry --> shmem_get_inode() // get an inode --> alloc_file() // allocate a file object
shmem --> alloc_file() // allocate a file object --> do_mmap_pgoff() // map the file object --> shm_may_destroy() // check if other process destroying this shmem --> shm_destroy() // other process destorying this shmem --> shm_unlock() // no one destorys this shmem
ipc_namespace *ns; 53 struct file *file; 54 const struct vm_operations_struct *vm_ops; 55 }; w ҎԼͷσʔλΛઃఆ w JEʹLFZ w OTʹΧϨϯτϓϩηεͷJQDOBNFTQBDF w JQDOBNFTQBDFͷϦϑΝϨϯεΧϯλΛΠϯΫϦϝϯτ͢Δ w pMFʹOFXTFH Ͱ࡞ͨ͠ϑΝΠϧΦϒδΣΫτ w WN@PQTʹ/6--
using this segment --> shm_destroy() // anyone using it --> shm_rmid() // remove id from namespace and segment's list --> shm_unlock() --> shm_lock() // if shmflg is not SHM_HUGETLB --> user_shm_unlock() // else if (struct shmid *)- >mlock_user isn't 0 --> fput() // remove file object
w TINFN@MPDL Ͱηάϝϯτ͕TXBQېࢭʹͳ͍ͬͯͨΒڐՄ͢ΔΑ͏ʹઃఆ w ͘͠NMPDL͞Ε͍ͯΔ߹ w ڞ༗ϝϞϦͰ༻͢ΔNMPDLରͷϖʔδΛTUSVDUVTFSͷMPDLFE@TIN͔ ΒݮΒ͢ w GQVU ͰOFXTFH Ͱ࡞ͨ͠ηάϝϯτ༻ͷϑΝΠϧΦϒδΣΫτΛআ