Re: fork question




"Eric" <nospam@xxxxxxxxx> wrote in message
news:VLednYl3AqJrZU7eRVn-gA@xxxxxxxxxxxxxx

> Well, most of it is that the child reads parent set data, but also, i have
> a
> couple of shared ints that can be set by anyone which are used as yes/no
> flags. once set, they never change but are read (ie checked) fairly often
> by the reset of the processes.

If they're set before the call to 'fork' and never change, they don't
need to be shared. There's no problem with the child making its own copy
during the call to 'fork'.

> Another q.
> I'm creating the mmap'd are like this (shortened for clarity):
>
> Global declarations:
> void *mptr;
> typedef struct _TSharedAreaMap {
> struct info sinfo[MAX_SINFOs];
> int Flag1;
> volatile int AbortOps;
> }TSharedAreaMap;
> TSharedAreaMap *SharedAreaMap;
>
> Mapping function:
> fd = open(SharedBackingFile, O_RDWR);
> mptr = mmap(0, Len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
> SharedAreaMap = (TSharedAreaMap *)mptr;
>
> Parent and child both call this but only the parent creates the backing
> file. Is that corect?

Why should both parent and child call that? Why not just call it before
you 'fork'?

DS


.



Relevant Pages

  • Re: Update Parent-Child-Grandchild Table
    ... hierarchy with three levels? ... I am also trying to update the parent at level 2 and> the child at level 3. ... > Parent INT NOT NULL, ...
    (microsoft.public.sqlserver.programming)
  • Re: About sleep() in child process
    ... int main{ ... beacuse of the scheduler.Due to which the loop in the parent is ... Child: PID is 11059 ... Parent: PID is 11058 ...
    (comp.lang.c)
  • Re: Quicksort
    ... replying to appeared to be missing a level of quote indicators. ... parent =; ... child = parent * 2; ... void Swap(int *arr, int i, int j) ...
    (comp.programming)
  • Re: unix pipe problems
    ... that's one way for the parent to tell the child it's finished sending. ... child reads from the pipe it will have wordsize initialized. ... int main ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)