[Serdev] Re: [Serusers] Sharing memory between child processes

Jiri Kuthan jiri at iptel.org
Sun May 30 18:29:54 UTC 2004


At 05:16 PM 5/30/2004, GUSTAVO GARCIA BERNARDO wrote:
>Hi,
>
>I'm developping a ser module and i have the problem of sharing some global variables between forked childs.  How can i solve this issue?
>
>For example if i would like to mantain in memory a counter of received messages.

Use shared memory. If needed for operations like counter incrementing, lock access to it.
Example code implementing synchronized access to shared memory you may wish to study
is usrloc module. An alternative method in cases like these is to write to shared memory 
owned by each individual process and calculate the sum over values owned by each process. 

You need to be careful about typical locking pitfalls -- make sure you unlock what you
locked to avoid deadlocks and make sure that the time spent in locks is short.

>I not interested in a database solution.

Thank you for your insights into what you are not interested in.

-jiri 




More information about the Serdev mailing list