Implementing `fork' in a single address space

Michael Meissner meissner at dg-rtp.dg.com
Tue Dec 12 04:33:51 AEST 1989


In article <10131 at june.cs.washington.edu> pardo at cs.washington.edu (David Keppel) writes:

|  I'd like to write a micro-unix to run in a single Un*x address space.
|  I'm having problems figuring out how to implement `fork' correctly in
|  one address space.  Perhaps it's impossible.  I'm willing to have
|  stack frames point at the other guy's data, but the only ways that I
|  can think of to get stacks to return right are:
|  
|  * To walk back the stack and patch up the retunr addresses -- scary!
|  
|  * Have all stacks live at one place in the address space.  That
|    requries swapping stacks at every context switch.
|  
|  Perhaps a related question:
|  
|  * Are there any pd (public-domain, or freeware) micro-unicies that I
|    can look at?  I remember that you used to be able to get a 3-ring
|    binder with the version 6 source, but I don't know if you had to
|    have a source liscence and all that.
|  
|  Thoughts?  Thanks!

Another way to do it is with a consenting compiler, and no hostile
assembly language programs.  Basically you teach the compiler to
ignore one or two of the {address} registers, and then every reference
to data and text is based off of these registers.  To do a context
switch, the kernel merely saves the registers, and loads up the new
registers.  To do a fork, the OS then allocates a new area somewhere,
sets up the one or two registers as appropriate, and fires off the
child.
--
--
Michael Meissner, Data General.
Until 12/15:	meissner at dg-rtp.DG.COM
After 12/15:	meissner at osf.org



More information about the Comp.unix.questions mailing list