You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Mihir Mohan <mi...@gmail.com> on 2005/06/08 16:48:34 UTC
Queries related to SHM
hi
I am writing a module to enable dynamic configuraiton. The way i do it is :
1. At the time of module boot up :
-I parse the configuration file and populate my configuration
object Configuration.cpp
-I initialize the shared memory with the size of the struct given below
-I have a struct as shown below :
typedef struct MyConfiguration{
int counter;
Configuration * myConfig; //A c++ object reference
}MyConfiguration;
-I put the above struct in the shm
-
2. At the time of request :
- myConfiguration = (Configuration*)apr_shm_baseaddr_get(my_shm);
- I retrieve the primitive value 'counter'
int counter = myConfiguration->counter
- increment it
- i get the right value across the processes
- I get the referenced value myConfig
myConfiguration->myConfig
- I update it
myConfiguraiton->myConfig->requestCount = 50;
- This updated value does not get reflected in the next process
I have following questions :
1. Since all the processes store different memory locations for the
same reference in the shared memory, how do i align it within a
process to get the correct value ? I observed that with primitive
types, it automativally gets aligned by getting the base address.
However, with structs/class references, it does not. How do i do it ?
Thanks in advance for your help.
Regards
Mihir Mohan
--
There is nothing more difficult to take in hand, more perilous to
conduct, or more uncertain in its success, than to take the lead in
the introduction of a new order of things.
Machiavelli in 'The Prince'