Difference between revisions of "Shared memory"

From ThorstensHome
Jump to: navigation, search
 
m (1 revision(s))
 

Latest revision as of 10:09, 18 October 2008

Here is an example how two processes communicate using shared memory with PHP on Linux:

tstaerk@tstaerk-laptop:~$ cat test.php
<?
$shm=shm_attach(2);
shm_put_var($shm,1,"blah");
echo shm_get_var($shm,1);
?>
tstaerk@tstaerk-laptop:~$ cat test2.php
<?
$shm=shm_attach(2);
echo shm_get_var($shm,1);
?>
tstaerk@tstaerk-laptop:~$ php test.php
blahtstaerk@tstaerk-laptop:~$ php test2.php
blahtstaerk@tstaerk-laptop:~$ 

See also