home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 160.lha / BCPL / process.doc < prev    next >
Text File  |  1988-04-27  |  3KB  |  56 lines

  1.                                 PROCESS CREATION
  2. Author: Bill Kinnersley
  3. Date: Mar 12, 1988
  4. Mail: Physics Dept.
  5.       Montana State University
  6.       Bozeman, MT 59717
  7. BITNET: iphwk@mtsunix1
  8. INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu
  9. UUCP: ...psuvax1!mtsunix1.bitnet!iphwk
  10.         There are several ways of creating a process on the Amiga.
  11.         At the lowest level is AddTask(task, initialPC, finalPC),
  12. which adds a given task to the TaskReady list.  Here task is an existing
  13. initialized Task structure, initialPC is the entry point, and finalPC
  14. is an optional cleanup routine.  The final code is pushed on the stack
  15. as if it were the outermost return address.  If finalPC is 0, the system
  16. default cleanup is to call RemTask(), which removes the task from the Ready
  17. list.  It deallocates the MemEntry list, but not the Task structure.  The
  18. task's registers are initially set to 0, except for SP, which is set to
  19. SPReg.  The user may reserve space for initial data by specifying
  20. SPReg < SPUpper.
  21.         At the next level is createproc(segarray, stkszlw, pri, ^name, ^gv).
  22. (The internal AmigaDOS function, function 84, at ff4586).  Both NewCLI and
  23. Run call this function.  It:
  24.         Allocates memory for Process structure and stack, and puts this
  25.                 on the MemList
  26.         Fills the Task, Process, and DOS MsgPort:
  27.                 SigWait for signal 8, and default TrapCode = ff4b6a
  28.         Reserves stack space to hold the Process name
  29.         Copies the parent's Console Handler, File Handler, and Window
  30.         AddTask()'s with special initPC and finalPC.
  31.                 The finalPC code frees the SegArray.
  32.                 The initPC code:
  33.         Fills the stack with "tttu", terminating with -1 and SP;
  34.         Sets the BCPL coroutine list to point to SPLower;
  35.         Looks at the Segarray.  If there is more than one entry, it calls
  36.                 GetSegList to fill in the GV;
  37.         It then fills in a5 and a6, waits for a startup packet, and
  38.                 then calls the program code at 4(a2).
  39. The external AmigaDOS function CreateProc(*name, pri, seg, stkszb) is
  40. function -48 at ff46bc.  In this case only a seglist is supplied, and
  41. thus the call must create its own SegArray.
  42.         The name buffer is subtracted from the stack request
  43.         20 bytes are AllocMem'ed for the SegArray.
  44.         The GV is obtained from DosLib
  45.         The Task, Process and MsgPort are initialized as above
  46.         The SPReg and ReturnAddr set
  47.         The 1st and 2nd SegList are copied from the parent, the 3rd
  48.                 SegList is the one supplied by caller, but the SegArray
  49.                 length is set to 2
  50.         AddTask() is called, with initPC = 1st SegList, and finalPC the
  51.                 same as above.
  52.         The next level is function 1c0 at ff61e0, which calls either
  53. 84 or -48, depending on the flags it is passed.  It is called by no one?
  54.         1a0 (at ff5328) is an execute call, which calls -54 at ff53b4
  55. (calls 144, at ff717c, loadseg), then 148 at ff7af0, unloadseg.
  56.