Found at: http://publish.ez.no/article/articleprint/46 |
Inter-Process Communication in PHP |
Luis returns with an article covering the real computer science stuff, how to use shared memory and semaphores.
Inter-Process Communication in PHP
Luis Argerich (Salutia.com)
Luis returns with an article covering the real computer science stuff, how to use shared memory and semaphores.
"Preoptimization is the root of all evil (Donald Knuth)"
--enable-shmop --enable-sysvsem |
$shm_id = shmop_open($key, $mode, $perm, $size); |
$shm_id = shmop_open(0xff3, "c", 0644, 100); |
------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00280267 0 root 644 1048576 3 0x00000000 1 nobody 600 46084 10 dest 0x00000000 2 nobody 600 46084 8 dest 0x00000ff3 131 nobody 644 100 0 ------ Semaphore Arrays -------- key semid owner perms nsems status 0x00280269 0 root 666 14 ------ Message Queues -------- key msqid owner perms used-bytes messages |
shmop_delete($id); |
int shmop_write (int shmid, string data, int offset) |
string shmop_read (int shmid, int start, int count) |
int sem_get (int key [, int max_acquire [, int perm]]) |
int sem_acquire (int sem_identifier) int sem_release (int sem_identifier) |
$semid=sem_get(0xee3,1,0666); $shm_id = shmop_open(0xff3, "c", 0644, 100); sem_acquire($semid); /* If we are here we are alone! */ WRITE TO THE SHARED SEGMENT HERE sem_release($semid); |