next up previous contents
下一主题: 系统调用:shmget() 上一层: 内部数据和用户数据 前一主题: 内部数据和用户数据

内核shmid_ds结构体

与消息队列和信号量集一样,内核为存在于其地址空间中的每个共享内存段维护一个特殊的内部数据结构。 此结构体的类型为shmid_ds,并在以下文件中定义linux/shm.h如下所示


        /* One shmid data structure for each shared memory segment in the system. */
        struct shmid_ds {
                struct ipc_perm shm_perm;        /* operation perms */
                int     shm_segsz;               /* size of segment (bytes) */
                time_t  shm_atime;               /* last attach time */
                time_t  shm_dtime;               /* last detach time */
                time_t  shm_ctime;               /* last change time */
                unsigned short  shm_cpid;        /* pid of creator */
                unsigned short  shm_lpid;        /* pid of last operator */
                short   shm_nattch;              /* no. of current attaches */

                                                 /* the following are private */

                unsigned short   shm_npages;     /* size of segment (pages) */
                unsigned long   *shm_pages;      /* array of ptrs to frames -> SHMMAX */ 
                struct vm_area_struct *attaches; /* descriptors for attaches */
        };

对此结构体的操作由特殊的系统调用执行,不应直接进行修改。 以下是更相关的字段的描述

shm_perm

这是ipc_perm结构体的实例,该结构体在以下文件中为我们定义linux/ipc.h。 这保存了该段的权限信息,包括访问权限以及有关段的创建者的信息(uid 等)。

shm_segsz

段的大小(以字节为单位)。

shm_atime

最后一个进程连接到该段的时间。

shm_dtime

最后一个进程分离该段的时间。

shm_ctime

上次对此结构体进行更改的时间(模式更改等)。

shm_cpid

创建进程的 PID。

shm_lpid

最后一个对该段进行操作的进程的 PID。

shm_nattch

当前连接到该段的进程数。



转换于
1996年3月29日 星期五 14:43:04 EST