Re: fork question




"Eric" <nospam@xxxxxxxxx> wrote in message
news:EeKdnbFBwIw0aU7enZ2dnUVZ_tOdnZ2d@xxxxxxxxxxxxxx

> if i use fork in my userland app, how do share a global variables between
> the parent and all the children? I need to have this variable created such
> that if anyone (parent or child) changes it all the other children and the
> parent can see the change. My only idea is a mmap'd space, I could let
> each
> process mmap the same space and use it for various shared variables, kind
> of like this:
> parent: create typedef of layout of mapped space
> parent: sp=mmap new shared space based on size of layout
> parent: sp->var1 = value
> parent: sp->var2 = value
> child1: sp=mmap existing shared space
> child1: sp->var1 = value
> child1: if(sp->var2 == value)...
> child2: sp=mmap existing shared space
> child2: sp->var1 = value
> child2: if(sp->var2 == value)...
> Is there another better way?

Have the parent create a shared memory area before it 'fork's. However,
you seem to be missing the important detail that if two processes are going
to share a memory area, they must synchronize their accesses to it (or use
atomic operations).

DS


.



Relevant Pages

  • fork question
    ... if i use fork in my userland app, how do share a global variables between ... that if anyone (parent or child) changes it all the other children and the ... create typedef of layout of mapped space ... sp=mmap new shared space based on size of layout ...
    (comp.os.linux.development.apps)
  • Re: book on wxPython?
    ... Many programmers aren't even used to the idea of layout ... hierarchies. ... Windows programmer. ... A child widget is within its parent - it will be clipped to ...
    (comp.lang.python)
  • Re: Method to do live resizing in a JFrame?
    ... some layout manager I found at sun's tutorial. ... * @param scale boolean true si les composants sont redimensionnés ... public void layoutContainer(Container parent) { ... This specifies how ...
    (comp.lang.java.gui)
  • Re: node.innerHTML = ... not working in IE
    ... > refraction of the page layout, ... > and it is not the parent of. ... - as the obvious DOM standard alternative ...
    (comp.lang.javascript)
  • finding within two fields
    ... so now i have moved on to the finding layout and am having a few ... would like to search for a particular trait in either parent. ... either the mother or the father with blue eye color shows up, ... father had black eyes. ...
    (comp.databases.filemaker)