内核当中信号量的数据结构,跟命名空间是相关的,给定的进程属于task_struct->nsproxy->ipc_ns指向的命名空间,ipc_namespace结构如下:
点击(此处)折叠或打开
-
struct ipc_namespace {
-
refcount_t count;
-
struct ipc_ids ids[3];
-
...
- };
点击(此处)折叠或打开
-
struct ipc_ids {
-
int in_use;
-
unsigned short seq;
-
struct rw_semaphore rwsem;
-
struct idr ipcs_idr;
-
int max_idx;
-
int last_idx; /* For wrap around detection */
-
#ifdef CONFIG_CHECKPOINT_RESTORE
-
int next_id;
-
#endif
-
struct rhashtable key_ht;
- };
点击(此处)折叠或打开
-
struct kern_ipc_perm {
-
spinlock_t lock;
-
bool deleted;
-
int id;
-
key_t key;
-
kuid_t uid;
-
kgid_t gid;
-
kuid_t cuid;
-
kgid_t cgid;
-
umode_t mode;
-
unsigned long seq;
-
void *security;
-
-
struct rhash_head khtnode;
-
-
struct rcu_head rcu;
-
refcount_t refcount;
- };
点击(此处)折叠或打开
-
struct sem_array {
-
struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
-
time64_t sem_ctime; /* create/last semctl() time */
-
struct list_head pending_alter; /* pending operations */
-
/* that alter the array */
-
struct list_head pending_const; /* pending complex operations */
-
/* that do not alter semvals */
-
struct list_head list_id; /* undo requests on this array */
-
int sem_nsems; /* no. of semaphores in array */
-
int complex_count; /* pending complex operations */
-
unsigned int use_global_lock;/* >0: global lock required */
-
-
struct sem sems[];
- };
点击(此处)折叠或打开
-
struct sem_queue {
-
struct list_head list; /* queue of pending operations */
-
struct task_struct *sleeper; /* this process */
-
struct sem_undo *undo; /* undo structure */
-
struct pid *pid; /* process id of requesting process */
-
int status; /* completion status of operation */
-
struct sembuf *sops; /* array of pending operations */
-
struct sembuf *blocking; /* the operation that blocked */
-
int nsops; /* number of operations */
-
bool alter; /* does *sops alter the array? */
-
bool dupsop; /* sops on more than one sem_num */
- };
点击(此处)折叠或打开
-
struct task_struct{
-
...
-
#ifdef CONFIG_SYSVIPC
-
struct sysv_sem sysvsem;
-
struct sysv_shm sysvshm;
-
#endif
-
...
- };
点击(此处)折叠或打开
-
struct sysv_sem {
-
struct sem_undo_list *undo_list;
- };