From: Rob McCool <robm@netscape.com>
Newsgroups: netscape.devs-nsapi
Subject: Re: globals and threads... again
Date: Fri, 26 Jul 1996 19:11:59 -0700

Dan Gildor wrote: > I know that this has been batted around before.... but it would be > nice to get a final say-so about this from Netscape (and how about a > tech note on this?). > > So what exactly does happen when the main parent server forks off its > children.... regarding global variables and threads spun off during > the servers init phase? > > For instance, does each child server get its own copies of all the > globals declared in the NSAPI modules (such that if one child changes > one... the other children don't see the change) or does everyone share > some global memory segment?

Global and static variables are copied for each child server process. Changes in one do not affect the others. The server itself uses a small area of shared memory for statistics and that's all.

> Also, how does this pertain to threads? If the parent launches a > thread in a NSAPI init function, does that thread get duplicated for > all the children... or does there remain only one thread?

Unfortunately it varies from system to system. Under NT you get one thread. Under all UNIX except IRIX, you get duplicates. Under IRIX you get only the original.

--
Rob McCool, robm@netscape.com http://home.netscape.com/people/robm/
Stunt Programmer, Netscape Communications Corporation
It was working ten minutes ago, I swear...
Reproduced by permission of the author.