PHP Classes

shared memory , semaphore help please!

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  shared memory , semaphore help please!  
Subject:shared memory , semaphore help please!
Summary:help please!
Messages:2
Author:abhijitsharma
Date:2009-12-07 14:07:47
Update:2009-12-19 23:39:58
 

  1. shared memory , semaphore help please!   Reply   Report abuse  
Picture of abhijitsharma abhijitsharma - 2009-12-07 15:34:50
Hi Guys,

I am facing great problem, have tried different methods now I m completely annoyed :'(.

I want to maintain the location on the memory accessed by all the sessions

I am working on some application where I m suppose to make communication among sessions. So I though of using semaphore(shared memory with mutual exclusion) in PHP.



I don't know why the script always create new memory location with same key when ever I open the page, instead it should maintain the pointer, with the value.

In example below, when ever I change the value for location "1234"(shmop_open(1234, "c", 0644, 1)) still the value remains one or I think php creates new location have same key("1234") with value one.

I think when ever I open the page it creates new thread, and every thread creates new location on the memory. I dont know how to stop this.

Example:
<?php

$shm_id = shmop_open(1234, "c", 0644, 1);


if(!$shm_id)
{
echo "Error while creating the shared memory segment.\n";
}
else
{
echo "Memory created";
}
$shm_bytes_written = shmop_write($shm_id, "1", 0);

if($shm_bytes_written != strlen("1"))
{
echo "Error while writing data\n";
}

$my_string = shmop_read($shm_id, 0, 1);
echo "....Value.... =". $my_string;
shmop_close ( $shm_id );
?>

(I can provide you with my attachment) please go through this.


Thanks
-Abhijit


Your help and new ideas will be appreciated.

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.