linux c 进程间 系统通信

这篇博客详细介绍了Linux中使用`ipcs`命令查看和管理进程间通信(IPC)资源,包括消息队列、共享内存段和信号量。展示了如何通过`ipcs`展示各种IPC设施的状态、限制及使用情况,如消息队列的长度限制、共享内存的大小限制等。此外,还提及了IPC状态的摘要信息,如消息队列的使用数量、共享内存段的分配和使用情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux c 进程间 系统通信

ipcs -h


Usage:
 ipcs [resource-option...] [output-option]
 ipcs -m|-q|-s -i <id>

Show information on IPC facilities.

Options:
 -i, --id <id>  print details on resource identified by <id>
 -h, --help     display this help and exit
 -V, --version  output version information and exit

Resource options:
 -m, --shmems      shared memory segments
 -q, --queues      message queues
 -s, --semaphores  semaphores
 -a, --all         all (default)

Output options:
 -t, --time        show attach, detach and change times
 -p, --pid         show PIDs of creator and last operator
 -c, --creator     show creator and owner
 -l, --limits      show resource limits
 -u, --summary     show status summary
     --human       show sizes in human-readable format
 -b, --bytes       show sizes in bytes

For more details see ipcs(1).

ipcs -a


------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x200258d4 0          jack       660        0            0
0x6b020001 32769      jack       666        16384        16

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 65536      lightdm    600        524288     2          dest
0x00000000 163841     lightdm    600        524288     2          dest
0x00000000 196610     lightdm    600        67108864   2          dest
0x00000000 327684     lightdm    600        1048576    2          dest

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

used-bytes 是总共使用的字节数量

限制

ipcs -l

------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18014398442373116
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 32000
max semaphores per array = 32000
max semaphores system wide = 1024000000
max ops per semop call = 500
semaphore max value = 32767

16384 字节 = 16k字节

ipcs -u


------ Messages Status --------
allocated queues = 2
used headers = 16
used space = 16384 bytes

------ Shared Memory Status --------
segments allocated 4
pages allocated 16896
pages resident  1327
pages swapped   0
Swap performance: 0 attempts     0 successes

------ Semaphore Status --------
used arrays = 0
allocated semaphores = 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值