免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2055 | 回复: 3
打印 上一主题 下一主题

看了HonestQiao的文章,请教关于PHP共享内存信号量的限制问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-17 14:14 |只看该作者 |倒序浏览
拜读了HonestQiao的一遍帖子 http://bbs.chinaunix.net/viewthread.php?tid=669627&page=1
有点想法,想用PHP的共享内存做个统计程序,用Semaphores做同步互斥的信号
实际运用中遇到点问题:
1. Shared Memory 的key个数受限制,分配191个key后就再已无法写入了
2. Semaphores 的key个数也受限制,分配10个后就再已无法写入了,导致过多的进程在等待信号量
不知何故,请高手赐教呀,谢谢谢谢谢谢谢谢谢谢谢谢了!

论坛徽章:
0
2 [报告]
发表于 2006-01-17 15:36 |只看该作者
我找到问题所在了,提示:
Warning: shm_attach() [function.shm-attach]: failed for key 0x39550fc: No space left on device
原来是没有空间了
在PHP的文档中找到:
SHMMAX max size of shared memory, normally 131072 bytes
SHMMIN minimum size of shared memory, normally 1 byte
SHMMNI max amount of shared memory segments on a system, normally 100  
SHMSEG max amount of shared memory segments per process, normally 6

不知道这个SHMMAX max size of shared memory, normally 131072 bytes 是一个块的最大值还是全部的,如果是全部的,我现在的192×10240早已超过这个数了
郁闷,继续。。。

论坛徽章:
0
3 [报告]
发表于 2006-02-10 11:47 |只看该作者
好像与系统相关,freebsd5.4,找到篇文章,相关:
# SYSV IPC KERNEL PARAMETERS
#
#options SEMMAP=512 #31 # Maximum number of entries in a semaphore map.
#options SEMMNI=512 #11 # Maximum number of System V semaphores that can be used on the system at one
time.
#options SEMMNS=1024 #61 # Total number of semaphores system wide
#options SEMMNU=512 #31 # Total number of undo structures in system
#options SEMMSL=256 #61 # Maximum number of System V semaphores that can be used by a single process a
t one time.
#options SEMOPM=256 #101 # Maximum number of operations that can be outstanding on a single System V semaphore
at one time.
#options SEMUME=512 #11 # Maximum number of undo operations that can be outstanding on a single System
V semaphore at one time.

# SYSV Shared Memory and Tunable Parameters
#
#options SHMALL=65536 #1025 # Maximum number of shared memory pages system wide.
#options SHMMAX=(SHMMAXPGS*PAGE_SIZE+1)
#options SHMMAXPGS=65535 #8192 # Maximum size, in bytes, of a single System V shared memory region.
#options SHMMIN=2 # Minimum size, in bytes, of a single System V shared memory region.
#options SHMMNI=256 #33 # Maximum number of shared memory regions that can be used on the system at on
e time.
#options SHMSEG=256 #9 # Maximum number of System V shared memory regions that can be attached to a single pr
ocess at one time.

# System V compatible message queues
# Please note that the values provided here are used to test kernel
# building. The defaults in the sources provide almost the same numbers.
# MSGSSZ must be a power of 2 between 8 and 1024.
#options MSGMNB=8192 #2049 # Max number of chars in queue
#options MSGMNI=256 #41 # Max number of message queue identifiers
#options MSGSEG=8192 #2049 # Max number of message segments
#options MSGSSZ=16 #16 # Size of a message segment
#options MSGTQL=128 #41 # Max number of messages in system

马上编译内核看一下,是不是这个问题

论坛徽章:
0
4 [报告]
发表于 2006-02-10 16:28 |只看该作者
你可以在一块内存里存较多数据啊, 而不是切成一小块一小块的当成堆栈变量在用...
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP