4 $MESSAGE_KEY = ftok(realpath(dirname(__FILE__)), "c");
5 $LOCKING_KEY = ftok(realpath(dirname(__FILE__)), "l");
6 $STORE_KEY = ftok(realpath(dirname(__FILE__)), "s");
8 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
11 function __construct()
13 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
14 $this->semres = sem_get($LOCKING_KEY, 0666);
15 $this->msgres = msg_get_queue($MESSAGE_KEY, 0666);
18 function getConfig($type=0)
20 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
21 sem_acquire($this->semres);
22 $shm_space = shm_attach($STORE_KEY, 16*1024*1024);
23 $config = shm_get_var($shm_space, $type);
24 sem_release($this->semres);
30 // type = 0 for the main config
31 // type = 1 for the boot hardware config
32 function putConfig($config, $type=0)
34 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
35 sem_acquire($this->semres);
36 $shm_space = shm_attach($STORE_KEY, 16*1024*1024);
37 shm_put_var($shm_space, $type, $config);
38 sem_release($this->semres);
41 function waitForMessage()
43 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
44 $queue = msg_get_queue($MESSAGE_KEY);
45 msg_receive($queue, 0, $msgtype, 1024, $msg);
50 function sendMessage($msg)
52 global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
53 $queue = msg_get_queue($MESSAGE_KEY);
54 msg_send($queue, 1, $msg);
58 private $semres, $msgres;