🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: mod.computers.68k
2 messages
2 total messages Started by cmcmanis Wed, 18 Feb 1987 18:30
Submission for mod-computers-68k
#164
Author: cmcmanis
Date: Wed, 18 Feb 1987 18:30
35 lines
2036 bytes
Path: sun!cmcmanis
From: cmcmanis@sun.uucp (Chuck McManis)
Newsgroups: mod.computers.68k,comp.sys.amiga
Subject: Fork() under AmigaDOS and others
Keywords: fork(), shared memorry
Message-ID: <13545@sun.uucp>
Date: 18 Feb 87 18:30:00 GMT
Organization: Sun Microsystems, Inc. - Mtn View, CA
Lines: 25

With all the discussion about fork() and why you can or cannot do it
without an MMU, I thought of a solution that I haven't seen proposed
yet. 

On the Amiga executables are stored in a runtime loadable format, and
there is a system call LoadSeg() that will load the executable into
memory and fix up all the variable references. So why can't fork()
simply read in a new copy of the executable from disk, peek at the 
address of it's data hunks, and copy the variables from the current
process to the new process, duplicate the stack, and then kick it off
with CreateProc() to make it run. You would then have two copies of 
the code running simultaneously and not have to worry about 'swapping'
back and forth. 

I have not figured out if one would have to muck with such things as
duplicating the current memory allocated by the parent process, and
if so fix up such things as linked lists of data structures. 

Comments anyone? Anyone know how Lattice 3.10 does fork() ?


-- 
--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
Re: Submission for mod-computers-68k
#167
Author: bandy
Date: Thu, 19 Feb 1987 03:11
61 lines
3669 bytes
>From: cmcmanis@sun.uucp (Chuck McManis)
>With all the discussion about fork() and why you can or cannot do it
>without an MMU, I thought of a solution that I haven't seen proposed
>yet. 
>
> [why not just get a clean copy of the unrelocated executable off of
>  disk,ala amiga's dos, and copy the data space and stack?]

>I have not figured out if one would have to muck with such things as
>duplicating the current memory allocated by the parent process, 

Yes, you would.

>and
>if so fix up such things as linked lists of data structures. 

It would be difficult.  For the compiler to put enough (uh) "bugs" in to allow
the operating system to know what to fool with during a fork would be a
*large* performance hit.

As to duplicating the stack, what happens when you have char *s; auto ca[666];
s = &ca; in your scheme?  Whoops!  Pointing at the wrong area of memory!

In fact, I wrote a little article today about how Tanenbaum's friend who is
doing the ST port is working it - and since you probably don't read
comp.sys.atari.st, I'll duplicate it here:

From: bandy@amdcad.UUCP (Andy Beals)
Newsgroups: comp.sys.atari.st
Subject: Multitasking discussion

Well, as you may know, Andy Tanenbaum has mentioned a number of times
that a friend of his is working on a port of minix to the ST.  Well, I
was curious as to which method was being used (planned on being used? I
don't know how far along that port is), so I dropped a note off to him
and found out that when processes are loaded, they are relocated on the
fly -- apparently the same method that the Amiga folks use.  When a
process forks, the child is "swapped" to somewhere in memory (wherever
there is enough room).  When the scheduler starts the child, it swaps
out the parent (to somewhere else in memory), swaps the child to where
the parent [was] and starts running the child -- this way all the text and
data references are okay. 

In most cases, the child will exec so the new process being loaded in
can go anywhere and the parent process can go back to where it
belongs.  This all should happen within one scheduler tick, so you
won't have to do more than four copies of the parent's process image if
you're careful // however, if you're really careful, you could get away
with two copies (for the fork/exec case) -- copy the parent, run the
child (where the parent was), when the child execs, copy the parent
back to where it belongs You might be able to get away with not copying
the parent back *just shuffle the pointers), but with no read-only
pages (no mmu), you have no guarantees that the child hasn't scribbled
all over the data or text pages).

Yes, I know, this sounds gross, but it isn't too bad -- after all, if you do
want your machine to go faster, you can wait until one of the home-computer
manufacturers comes out with a cheap machine with an MMU and then run Minix
on it.
-- 
Andrew Scott Beals, {lll-crg,decwrl,allegra}!amdcad!bandy +1 408 749 3683
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads