home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / programm / 12922 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.7 KB  |  73 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!adastra!mbs
  2. From: mbs@adastra.cvl.va.us (Michael B. Smith)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: OS/2 vs. AmigaOS
  5. Distribution: world
  6. Message-ID: <mbs.0x0r@adastra.cvl.va.us>
  7. 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>
  8. X-NewsSoftware: GRn 1.16f (beta) by Mike Schwartz & Michael B. Smith
  9. Date: 31 Aug 92 20:05:01 EDT
  10. Organization: Private UUCP Node
  11. Lines: 60
  12.  
  13. In article <BtuypA.5zq@gpu.utcs.utoronto.ca> engb@gpu.utcs.utoronto.ca (Ben Eng) writes:
  14. > Every unix hacker wishes for an equivalent to fork() on the amiga,
  15. > but we'll never see it.  Wild's ixem library offers a vfork(),
  16. > I believe.  I wonder just how usable that vfork() is in real
  17. > life.  What are it's limitations (there must be some)?
  18.  
  19. It's a real honest-to-gosh vfork(). I used it extensively in my port of "ash".
  20. It has, actually, a couple of additional things that it does to make it more
  21. useful: it creates new copies of all open fd's (non-exclusive), a copy of the
  22. stack is made.
  23.  
  24. If you take GREAT care, you can simulate a fork() using vfork() and vfork_resume()
  25. (which lets the parent resume), but you have to copy global memory areas, and
  26. use some tricks to do a geta4() inline call.
  27.  
  28. Unless you use some of these extensions, it looks like a standard vfork().
  29. Be VERY careful not to return back on top of the caller's stack though. If you
  30. do, you've screwed yourself (this is "undefined" in SVR4 anyway, I don't know
  31. what BSD says).
  32.  
  33. A very small piece of sample code from an early beta of pdksh is appended.
  34. Markus' standard copyright and copyleft apply.
  35. --
  36.   //   Michael B. Smith
  37. \X/    mbs@adastra.cvl.va.us  -or-  uunet.uu.net!virginia.edu!adastra!mbs
  38.  
  39. unsigned int inline static geta4 ()
  40. {
  41.   u_int res;
  42.   asm ("movel   a4,%0" : "=g" (res));
  43.   return res;
  44. }
  45. static inline int dbsize()
  46. {
  47.   int res;
  48.   asm ("movel #___data_size,%0; addl #___bss_size,%0" : "=r" (res));
  49.   return res;
  50. }
  51. extern int __datadata_relocs();
  52.  
  53.         .....
  54.         if (i == 0) {           /* child */
  55. #ifdef amigados
  56.                 extern char **_ctype_, **environ;
  57.                 extern int sys_nerr;
  58.                 extern int SysBase, DOSBase;
  59.  
  60.                 /* reinit stdio */
  61.                 ix_get_vars2 (6, &_ctype_, &sys_nerr, &SysBase, &DOSBase, &__sF, &environ);
  62.                 fopenshf(0);    fopenshf(1);    fopenshf(2);
  63.  
  64.                 ix_resident (4, geta4(), dbsize(), __datadata_relocs);
  65.                 vfork_resume ();
  66.  
  67.                 ainit (&e.area);
  68.                 e.savefd = 0;
  69.  
  70.                 t = tcopy (t, ATEMP);
  71. #endif
  72.  
  73.