Re: Processes and Threads



On Sat, 15 Sep 2007 16:59:46 -0700 David Schwartz <davids@xxxxxxxxxxxxx> wrote:

| A thread (that is part of a process) can typically do two things:
|
| 1) Call a function like 'pthread_create' that creates an additional
| thread in the same process.
|
| 2) Call a function like 'fork' that creates a new process that starts
| with a single thread.

The inconsistency here is that the new process created contains an image
of a process state that looks like it has perhaps multiple threads running.
Each thread in the parent has its own stack. Which stack will the one new
thread in the child be using? There will at least be a lot more stuff the
child process has to clean up, like all the descriptors in use by all the
threads of the parent.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2007-09-16-2350@xxxxxxxx |
|------------------------------------/-------------------------------------|
.



Relevant Pages

  • Re: Fork and Closing Open Sockets
    ... :> background process that doesn't inherit any of the open file ... The alternative is to control this in the parent process by using ... fcntlto set the close-on-exec flag on file descriptors ... you don't want the child process to see. ...
    (comp.os.linux.networking)
  • Re: [9fans] APE fork()
    ... fork creates a child process that differs from the parent ... is an exact copy of the calling process (parent process) except for the ... The child process has its own copy of the parent's descriptors. ...
    (comp.os.plan9)
  • Re: fork() and script execution afterwards
    ... Tom Storey wrote: ... where it forked in the parent, which seems as though it is the case. ... The child process is created by cloning the parent's virtual memory, ... Including the stack, the return ...
    (comp.lang.perl.misc)
  • Re: vms versus solaris
    ... >> between Symbols and Logicals as I really thought they were pretty much ... A shell symbol that needs to be visible to a child process and/or ... Environment variables are passed down by child processes. ... child process are _NOT_ visible to the parent. ...
    (comp.os.vms)
  • Re: timing a fork
    ... if ($kid) { ... That is why I want the child process to be detached. ... But, I'm new to modperl, and I think a fork doesn't copy the ... What it does is say that the parent isn't interested in ...
    (perl.beginners)