* vfork on Dec Alpha buggy?
@ 1996-12-18 5:00 Carsten Hammer
1996-12-18 5:00 ` Ron Natalie
1996-12-19 5:00 ` Burkhard Neidecker-Lutz
0 siblings, 2 replies; 7+ messages in thread
From: Carsten Hammer @ 1996-12-18 5:00 UTC (permalink / raw)
This gives 6 but should give 7, not?
#include <sys/types.h>
#include <stdio.h>
int glob=6;
int main(void)
{
pid_t pid;
if((pid=vfork())<0)fprintf(stderr,"vfork error");
else if (pid==0){
glob++;
_exit(0);
}
printf("glob=%d\n",glob);
}
For Reference look at Richard W. Stevens 'Advanced Programming in the Unix
Environment'
Did i make a mistake?
I need it to compute processing times...
ciao
Carsten
--
Carsten Hammer Schwindstr. 7 33615 Bielefeld
chammer@POST.uni-bielefeld.de
chammer@d2hammer.physik.uni-bielefeld.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-18 5:00 vfork on Dec Alpha buggy? Carsten Hammer
@ 1996-12-18 5:00 ` Ron Natalie
1996-12-18 5:00 ` Pierre Asselin
1996-12-19 5:00 ` Burkhard Neidecker-Lutz
1 sibling, 1 reply; 7+ messages in thread
From: Ron Natalie @ 1996-12-18 5:00 UTC (permalink / raw)
VFORK isn't buggy on the ALPHA, it is absent entirely.
An unfortunate decision on DEC's part. The reason VFORK
is there at all is a kludge. Most UNIX commands do an
exec shortly after the fork. Unfortunately, fork causes
a complete duplication of the writable parts of the process.
Berkeley added VFORK to make the fork-then-exec paradigm
feature work efficiently. You were warned in the manual
page to be very, very, careful with this.
On machines with decent virtual memory systems, you can
set up the forked process to be copy-on-access from the
parent. This greatly succeeds in making the fork-then-
exec efficient as only the pages that are touched prior
to forking need to be copied. DEC and SGI are two of
the implementations that do this and have just replaced
vfork with fork.
Unfortunately, another problem looms it's ugly head.
Stupid swap space allocation. Many systems implement
a immediate swap reservation when a process starts (fork).
Now if you try to fork something trivial off from a large
VM process, things may die because the OS allocates enough
swap for another copy of the big process, when all that
is being started is some little program.
Fortunately, on the DEC you can get around this by turning
on lazy swap allocation (see the description of /etc/swapdefauts
in the swapon man page). However, much as I detest kludges,
I wish DEC would have left VFORK well enough alone.
-Ron
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-18 5:00 ` Ron Natalie
@ 1996-12-18 5:00 ` Pierre Asselin
1996-12-19 5:00 ` T. Horsnell (tsh)
1996-12-19 5:00 ` Ron Natalie
0 siblings, 2 replies; 7+ messages in thread
From: Pierre Asselin @ 1996-12-18 5:00 UTC (permalink / raw)
Ron Natalie wrote:
>[summary of why vfork() was added to BSD, why copy-on-write
> obsoletes the original motivation, and why swap allocation
> makes one want a vfork() after all.]
> Fortunately, on the DEC you can get around this by turning
> on lazy swap allocation (see the description of /etc/swapdefauts
> in the swapon man page). However, much as I detest kludges,
> I wish DEC would have left VFORK well enough alone.
I second your wish!
Lazy swap allocation is also a kludge. Programs can allocate
memory up to the virtual address limits; it's only when the
memory is used that processes start to die because there isn't
enough disk to back up the virtual memory.
Kludge for kludge, I prefer vfork.
--
Pierre Asselin, Quantum Recording Heads Group
asselin@qntm.com Home: pa@verano.sba.ca.us
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-18 5:00 ` Pierre Asselin
@ 1996-12-19 5:00 ` T. Horsnell (tsh)
1996-12-19 5:00 ` Ron Natalie
1 sibling, 0 replies; 7+ messages in thread
From: T. Horsnell (tsh) @ 1996-12-19 5:00 UTC (permalink / raw)
In article <32B887CB.41C6@qntm.com> Pierre Asselin <asselin@qntm.com> writes:
>Ron Natalie wrote:
>>[summary of why vfork() was added to BSD, why copy-on-write
>> obsoletes the original motivation, and why swap allocation
>> makes one want a vfork() after all.]
>
>> Fortunately, on the DEC you can get around this by turning
>> on lazy swap allocation (see the description of /etc/swapdefauts
>> in the swapon man page). However, much as I detest kludges,
>> I wish DEC would have left VFORK well enough alone.
>
>I second your wish!
>
>Lazy swap allocation is also a kludge. Programs can allocate
>memory up to the virtual address limits; it's only when the
>memory is used that processes start to die because there isn't
>enough disk to back up the virtual memory.
>
>Kludge for kludge, I prefer vfork.
>
I find lazy swap very handy, except that since V4.0 it seems to have taken to throwing
out root-owned processes (like inetd and xlogin) when trying to make swap space
in a filled swap area. Not very helpful...
Terry Horsnell
MRC Cambridge U.K.
tsh@mrc-lmb.cam.ac.uk
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-18 5:00 vfork on Dec Alpha buggy? Carsten Hammer
1996-12-18 5:00 ` Ron Natalie
@ 1996-12-19 5:00 ` Burkhard Neidecker-Lutz
1996-12-21 5:00 ` Linus Torvalds
1 sibling, 1 reply; 7+ messages in thread
From: Burkhard Neidecker-Lutz @ 1996-12-19 5:00 UTC (permalink / raw)
In article <E2M7CL.4q3@hermes.hrz.uni-bielefeld.de> chammer@hrz.uni-bielefeld.de (Carsten Hammer) writes:
> < program modifying a global variable under vfork in a child and hoping
> to see the change in the parent deleted>
>For Reference look at Richard W. Stevens 'Advanced Programming in the Unix
>Environment'
You are relying on undefined (or rather, implementation defined) behaviour.
BSD derived systems (such as Ultrix and SUNOS 4.1.3) will yield 7 on
your program, while machines with proper copy-on-write semantics even on
vfork will yield 6 (such as Digital Unix and Linux).
Burkhard Neidecker-Lutz
CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
email: neideck@kar.dec.com
433Mhz 21164, 64 MB RAM, 2.1 GB SCSI, SPEC95 12.6e/12.0e, Linux preinstalled
Just $4630,, See http://www.swt.com/alpha_linux for details
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-18 5:00 ` Pierre Asselin
1996-12-19 5:00 ` T. Horsnell (tsh)
@ 1996-12-19 5:00 ` Ron Natalie
1 sibling, 0 replies; 7+ messages in thread
From: Ron Natalie @ 1996-12-19 5:00 UTC (permalink / raw)
> Lazy swap allocation is also a kludge. Programs can allocate
> memory up to the virtual address limits; it's only when the
> memory is used that processes start to die because there isn't
> enough disk to back up the virtual memory.
Actually, neither swap method is ideal. Most UNIX implemenations
blow chunks on htis.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: vfork on Dec Alpha buggy?
1996-12-19 5:00 ` Burkhard Neidecker-Lutz
@ 1996-12-21 5:00 ` Linus Torvalds
0 siblings, 0 replies; 7+ messages in thread
From: Linus Torvalds @ 1996-12-21 5:00 UTC (permalink / raw)
In article <59b722$6k4@usenet.pa.dec.com>,
Burkhard Neidecker-Lutz <neideck@kar.dec.com> wrote:
>In article <E2M7CL.4q3@hermes.hrz.uni-bielefeld.de> chammer@hrz.uni-bielefeld.de (Carsten Hammer) writes:
>> < program modifying a global variable under vfork in a child and hoping
>> to see the change in the parent deleted>
>>For Reference look at Richard W. Stevens 'Advanced Programming in the Unix
>>Environment'
>
>You are relying on undefined (or rather, implementation defined) behaviour.
>BSD derived systems (such as Ultrix and SUNOS 4.1.3) will yield 7 on
>your program, while machines with proper copy-on-write semantics even on
>vfork will yield 6 (such as Digital Unix and Linux).
vfork() is an abomination, and should be shunned if possible. Burkhard
is correct in that both Digital UNIX and Linux will just silently do a
"fork()" regardless of what the user expected, in the hope that the user
doesn't care and just wants to get some old program that used vfork()
running.
However, future versions of Linux probably _will_ support traditional
vfork() behaviour, if only because it's pretty trivial to do with the
new Linux kernel threads model. That doesn't mean that I'd encourage
people to dust off their old programs, but if people really _want_ the
functionality I could code it up (only for Linux, though, don't expect
any OSF kernel patches from me ;)
Anybody who really has a program that would benefit from a "real"
vfork() on top of Linux is encoraged to contact me and tell me so, maybe
I'll get it going sooner that way..
Linus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1996-12-21 5:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-12-18 5:00 vfork on Dec Alpha buggy? Carsten Hammer
1996-12-18 5:00 ` Ron Natalie
1996-12-18 5:00 ` Pierre Asselin
1996-12-19 5:00 ` T. Horsnell (tsh)
1996-12-19 5:00 ` Ron Natalie
1996-12-19 5:00 ` Burkhard Neidecker-Lutz
1996-12-21 5:00 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox