文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>关于PHP共享内存信号量的限制问题

关于PHP共享内存信号量的限制问题

时间:2006-02-10  来源:cell1999

拜读了HonestQiao的一遍帖子
http://bbs.chinaunix.net/viewthread.php?tid=669627&page=1
有点想法,想用PHP的共享内存做个统计程序,用Semaphores做同步互斥的信号
实际运用中遇到点问题:
1. Shared Memory 的key个数受限制,分配192个key后就再已无法写入了
2. Semaphores 的key个数也受限制,分配10个后就再已无法写入了,导致过多的进程在等待信号量

再分配的时候发现了一个错误:
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早已超过这个数了
后来发现,与系统相关,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
马上编译内核,试一下

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载