通过eaccelerator 可以了解多种进程间共享的技术,参看: mm.c; 我们会发现,在linux上,这里实现了 5 中进程间共享内存的方式供我们选择使用。
linux 上编译PHP加速器: eaccelerator
[eaccelerator-0.9.6.1]# ./configure
…
checking for sysvipc shared memory support… yes
checking for mmap shared memory support… yes
checking for mmap on /dev/zero shared memory support… yes
checking for anonymous mmap shared memory support… yes
checking for posix mmap shared memory support… no
checking for best shared memory type… sysvipc
checking for spinlock semaphores support… yes
checking for pthread semaphores support… yes
checking for posix semaphores support… no
checking for sysvipc semaphores support… yes
checking for fcntl semaphores support… yes
checking for flock semaphores support… yes
checking for best semaphores type… spinlock
…
config后的config.h:
———————–
…
* Define if you like to use fcntl based semaphores */
/* #undef MM_SEM_FCNTL */
/* Define if you like to use flock based semaphores */
/* #undef MM_SEM_FLOCK */
/* Define if you like to use sysvipc based semaphores */
/* #undef MM_SEM_IPC */
/* Define if you like to use posix based semaphores */
/* #undef MM_SEM_POSIX */
/* Define if you like to use pthread based semaphores */
/* #undef MM_SEM_PTHREAD */
/* Define if you like to use spinlock based semaphores */
#define MM_SEM_SPINLOCK 1
/* Define if you like to use sysvipc based shared memory */
#define MM_SHM_IPC 1
/* Define if you like to use anonymous mmap based shared memory */
/* #undef MM_SHM_MMAP_ANON */
/* Define if you like to use mmap on temporary file shared memory */
/* #undef MM_SHM_MMAP_FILE */
/* Define if you like to use posix mmap based shared memory */
/* #undef MM_SHM_MMAP_POSIX */
/* Define if you like to use mmap on /dev/zero based shared memory */
/* #undef MM_SHM_MMAP_ZERO */
…
———————
其中:
semaphores 是用来实现锁的机制的,因为对共享内存的(写)操作一定要有锁的机制来保证的。eaccelerator 也还为我们提供了锁的相关函数。
shared memory 是用来缓存opcode的,eaccelerator也为我们提供了相关的函数用来缓存用户自定义的一些信息。
使用时的情况: