一个例子 ------ Shared Memory Segments -------key shmid owner perms 0 x 0052 e 6 a 9 0 postgres 600 0 x 0052 e 2 c 1 32769 postgres 600 bytes 38207488 ------ Semaphore Arrays -------key semid owner perms 0 x 0052 e 6 a 9 0 postgres 600 0 x 0052 e 6 aa 32769 postgres 600 0 x 0052 e 6 ab 65538 postgres 600 0 x 0052 e 6 ac 98307 postgres 600 0 x 0052 e 6 ad 131076 postgres 600 0 x 0052 e 6 ae 163845 postgres 600 0 x 0052 e 6 af 196614 postgres 600 0 x 0052 e 2 c 1 229383 postgres 600 0 x 0052 e 2 c 2 262152 postgres 600 0 x 0052 e 2 c 3 294921 postgres 600 0 x 0052 e 2 c 4 327690 postgres 600 0 x 0052 e 2 c 5 360459 postgres 600 0 x 0052 e 2 c 6 393228 postgres 600 0 x 0052 e 2 c 7 425997 postgres 600 nsems 17 17 17 17 ------ Message Queues -------key msqid owner used-bytes perms nattch 4 4 messages status
操纵消息队列 n 先通过ftok取得键值key n 打开或创建消息队列 int msgget(key_t key, int flag); n 发送消息 int msgsnd(int id, void *p, size_t nbytes, int flag); n 接收消息 ssize_t msgrcv(int id, void *p, size_t nbytes, long type, int flag);