home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TASK1.ZIP / TASKER.HDR < prev    next >
Encoding:
Text File  |  1988-08-06  |  3.6 KB  |  79 lines

  1. Unit Tasker;
  2. {
  3.   Non-Preemptive MultiTasking Unit
  4.   for Turbo Pascal Version 4
  5.  
  6.   Author  : Michael Warot - Blue Star Systems
  7.   Date    : November 1987
  8.   Purpose : Simple multi-tasking for turbo pascal 4.0
  9.   Version : 1.10
  10.  
  11.   V1.10  August    1988 MAW - Revise code, speed things up a bit.
  12.                               Yield went from 2000 uS to 250uS on an AT!
  13.   V1.04  March     1988 MAW - Modify record used to save process, now
  14.                               use a pointer instead of 2 words to save
  15.                               the stack frame.
  16.                               Eliminate redundant variable NextP
  17.   V1.03  March,    1988 MAW - Modify code to save video state for a given
  18.                               process. A flag Video_Save toggles this.
  19.   V1.02  March,    1988 MAW - Modify code to support Sleep Function
  20.                               Added procedures LOCK and UNLOCK to permit
  21.                               use of non-reentrant procedures in programs
  22.   V1.01  January,  1988 MAW - Remove obsolete startup function Init_Tasking.
  23.                               Put in some documentation. Clean up code.
  24.   V1.00  November, 1987 MAW - Initial version, simple and crude, but it works.
  25. }
  26. {$F+    Force FAR calls - must be on}
  27. Interface
  28. Uses
  29.   Crt;             { For saving screen status, etc }
  30.  
  31. Type
  32.   FlagPtr    = ^Boolean;                 { Pointer to a flag           }
  33. Var
  34.   Save_Video : Boolean;                  { True for cursor saving }
  35.  
  36. Function Fork:Boolean; { Call this procedure to spawn a new process. The
  37.                          procedure will return to your program twice. The
  38.                          first time it will be the root process, and will
  39.                          return a value of false, the second time it will
  40.                          return a value of true }
  41.  
  42. Procedure Yield;       { Call this procedure often in your code. This is the
  43.                          heart of the Multi-Tasking, it will return after all
  44.                          of the other processes have a crack at it.        }
  45.  
  46. Procedure Sleep(Flag : FlagPtr);
  47.                        { Call this procedure with an address of a flag which
  48.                          when TRUE, will re-awaken the process. Upon entry
  49.                          this procedure will test the value of this flag, and
  50.                          if FALSE, will mark the process HIBER.
  51.                          This procedure makes a call to YIELD in all cases.
  52.                          Note : Don't let all of you processes Sleep, or
  53.                          you could put things into a deadlock. }
  54.  
  55. Procedure Lock(Resource : Byte);
  56.                        { This procedure allows the programmer to insure that
  57.                          a procedure is not entered twice, it does this by
  58.                          having the second call yield until the resource is
  59.                          free, using Sleep }
  60.  
  61. Procedure UnLock(Resource : Byte);
  62.                        { This procedure unlocks a resource, allowing it to be
  63.                          used by other processes }
  64.  
  65. Procedure KillProc;    { This procedure is intended to be called by a process
  66.                          that has done all of it's work. It marks the process
  67.                          as one that is 'DEAD' and thus never re-awakens }
  68.  
  69. Function  Child_Process:Boolean;
  70.                        { This function returns True if the calling procedure
  71.                          is a child process. This test should be used to branch
  72.                          into a specific procedure for a given task.       }
  73.  
  74. Procedure SetPriority(P : Integer);
  75.  
  76. Function  ProcessCount:Integer;
  77.  
  78. Implementation
  79.