home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!adastra!mbs
- From: mbs@adastra.cvl.va.us (Michael B. Smith)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: OS/2 vs. AmigaOS
- Distribution: world
- Message-ID: <mbs.0x0r@adastra.cvl.va.us>
- References: <1992Aug28.175748.42640@kuhub.cc.ukans.edu> <1992Aug29.003212.13913@endicor.com> <1992Aug31.033347.17131@marlin.jcu.edu.au> <1992Aug31.042231.395@endicor.com> <BtuypA.5zq@gpu.utcs.utoronto.ca>
- X-NewsSoftware: GRn 1.16f (beta) by Mike Schwartz & Michael B. Smith
- Date: 31 Aug 92 20:05:01 EDT
- Organization: Private UUCP Node
- Lines: 60
-
- In article <BtuypA.5zq@gpu.utcs.utoronto.ca> engb@gpu.utcs.utoronto.ca (Ben Eng) writes:
- > Every unix hacker wishes for an equivalent to fork() on the amiga,
- > but we'll never see it. Wild's ixem library offers a vfork(),
- > I believe. I wonder just how usable that vfork() is in real
- > life. What are it's limitations (there must be some)?
-
- It's a real honest-to-gosh vfork(). I used it extensively in my port of "ash".
- It has, actually, a couple of additional things that it does to make it more
- useful: it creates new copies of all open fd's (non-exclusive), a copy of the
- stack is made.
-
- If you take GREAT care, you can simulate a fork() using vfork() and vfork_resume()
- (which lets the parent resume), but you have to copy global memory areas, and
- use some tricks to do a geta4() inline call.
-
- Unless you use some of these extensions, it looks like a standard vfork().
- Be VERY careful not to return back on top of the caller's stack though. If you
- do, you've screwed yourself (this is "undefined" in SVR4 anyway, I don't know
- what BSD says).
-
- A very small piece of sample code from an early beta of pdksh is appended.
- Markus' standard copyright and copyleft apply.
- --
- // Michael B. Smith
- \X/ mbs@adastra.cvl.va.us -or- uunet.uu.net!virginia.edu!adastra!mbs
-
- unsigned int inline static geta4 ()
- {
- u_int res;
- asm ("movel a4,%0" : "=g" (res));
- return res;
- }
- static inline int dbsize()
- {
- int res;
- asm ("movel #___data_size,%0; addl #___bss_size,%0" : "=r" (res));
- return res;
- }
- extern int __datadata_relocs();
-
- .....
- if (i == 0) { /* child */
- #ifdef amigados
- extern char **_ctype_, **environ;
- extern int sys_nerr;
- extern int SysBase, DOSBase;
-
- /* reinit stdio */
- ix_get_vars2 (6, &_ctype_, &sys_nerr, &SysBase, &DOSBase, &__sF, &environ);
- fopenshf(0); fopenshf(1); fopenshf(2);
-
- ix_resident (4, geta4(), dbsize(), __datadata_relocs);
- vfork_resume ();
-
- ainit (&e.area);
- e.savefd = 0;
-
- t = tcopy (t, ATEMP);
- #endif
-
-