home *** CD-ROM | disk | FTP | other *** search
- {
- ════════════════════════════════════════════════════════════════════════════
-
- Visionix Process/Procedure/Thread "Multitasking" Unit (VMULTI)
- Copyright 1991,92,93 Visionix
- ALL RIGHTS RESERVED
-
- DOS MultiTasker (non-preemptive). This unit makes it possible to time-slice
- program tasks, such as the system clock and other user provided procedures.
- Giving the program the ability to have multiple concurrent actions occuring
- all the time.
-
- ────────────────────────────────────────────────────────────────────────────
-
- Revision history in reverse chronological order:
-
- Initials Date Comment
- ──────── ──────── ────────────────────────────────────────────────────────
-
- lpg 03/16/93 Added Source Documentation
-
- mep 02/11/93 Cleaned up code for beta release
-
- jrt 02/08/93 Sync with beta 0.12 release
-
- jrt 12/07/92 Sync with beta 0.11 release
-
- jrt 11/21/92 Sync with beta 0.08
-
- jrt 09/01/92 First logged revision.
-
- ════════════════════════════════════════════════════════════════════════════
- }
-
- Unit VMulti;
-
-
- Uses
-
- VTypes,
- DOS;
-
- {────────────────────────────────────────────────────────────────────────────}
-
- Const
-
- VMS_New = 1;
- VMS_Do = 2;
- VMS_Dispose = 3;
-
- Type
-
- TMultiProc = Procedure( Status : BYTE; Var IData : Pointer );
-
- PMultiProcList = ^TMultiProcList;
-
- TMultiProcList = Record
-
- Proc : TMultiProc; { pointer to procedure }
- Interval : LONGINT; { interval between required processing }
- SPL : BYTE; { service processing level: }
- { 7=highest priority, 0 = lowest }
- Name : ST80; { process name }
- ID : Pointer; { process Instance Data }
- LastCall : LONGINT; { last call time }
- InProc : BOOLEAN; { already in procedure? }
-
- Next : PMultiProcList;
-
- END;
-
- TMachine = Record
-
- MultiProcListHead : PMultiProcList;
- MultiProcListCurr : PMultiProcList;
- MultiProcListTail : PMultiProcList;
-
- END;
-
- {────────────────────────────────────────────────────────────────────────────}
-
- Procedure VMultiProcNew( Prc : TMultiProc;
- Interval : LONGINT;
- SPL : BYTE;
- Name : TProcName;
- Var Error : WORD );
-
- Procedure VMultiProcDispose( Name : TProcName );
-
- Procedure VMultiProcSetSPL( Name : TProcName );
-
- Procedure VMultiThreadNew( Prc : Pointer;
- CallInterval : LONGINT;
- StayInterval : LONGINT;
- SPL : BYTE;
- Name : TProcName;
- StackSize : WORD;
- StackPtr : Pointer );
-
- Procedure VMultiThreadDispose( Name : TProcName );
-
- Procedure VMultiThreadSetSPL( Name : TProcName );
-
- Procedure VMultiDo( SPL : BYTE );
-
- Procedure VMultiSleep( Duration : WORD );
-
- Procedure VMultiCriticalBEGIN;
-
- Procedure VMultiCriticalEND;
-
- Procedure VMultiSetDVSPL( SPL : BYTE );
-
- Procedure VMultiSetWinSPL( SPL : BYTE );
-
- {────────────────────────────────────────────────────────────────────────────}
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiProcNew( Prc : TMultiProc;
- Interval : LONGINT;
- SPL : BYTE;
- Name : TProcName;
- Var Error : WORD );
-
- [PARAMETERS]
-
- Prc Pointer to Called Procedure
- Interval Time between updates in MilliSeconds
- SPL Service Processing Level (7=Highest,0=Lowest)
- Name Name of Process Action
- Handle VAR Returned Multi-tasking Process ID Number
- Error VAR Returned Error Code (0=Success)
-
- [RETURNS]
-
- Function : None
- (VAR : [Handle] Multi-tasking Process ID Number)
- (VAR : [Error] Error Code)
-
- [DESCRIPTION]
-
- Procedure to all for the submission and identification of Multitasking
- processes and their associated procedures. Returns a process ID number
- Allocates a new Multi-Procedure.
-
- Prc Pointer to Multi-Procedure.
-
- Interval Minimum wait between calls, in 100ths of a
- second.
-
- SPL System Priority Level. How "important"
- it is that this multi-proc gets called.
- 0 is most important, 10 is least.
-
- Name Name of the procedure.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiProcDispose( Name : TProcName );
-
- [PARAMETERS]
-
- Name Name of Process to Remove from List
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Removes processes from the Multi-Tasking Processing list.
- Disposes of a previously allocated multi-proc.
-
- Name Name of the procedure to dispose of.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiProcSetSPL( Name : TProcName );
-
- [PARAMETERS]
-
- Name Name of Process to set the SPL Level on
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiThreadNew( Prc : Pointer;
- CallInterval : LONGINT;
- StayInterval : LONGINT;
- SPL : BYTE;
- Name : TProcName;
- StackSize : WORD;
- StackPtr : Pointer );
-
- [PARAMETERS]
-
- Prc Pointer to New Thread Procedure
- CallInterval Time Between updates in Milliseconds
- StayInterval Amount of Processing Time to Spend at this Thread
- SPL Service Processing Level (7=Highest,0=Lowest)
- Name Name of Thread Processing Action
- StackSize Amount of Stack to Allocate to this Thread
- StackPtr Pointer to Allocated Stack
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiThreadDispose( Name : TProcName );
-
- [PARAMETERS]
-
- Name Name of Thread Procedure to Dispose of
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiThreadSetSPL( Name : TProcName );
-
- [PARAMETERS]
-
- Name Name of Thread Process to Set the SPL Level on
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiDo( SPL : BYTE );
-
- [PARAMETERS]
-
- SPL Service Processing Level (7=Highest,0=Lowest)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- This is the key function called to update all multitasking functions
- that are equal to or greater than the submitted processing level.
- Allows multi-procs of a priority <= SPL to run.
-
- Calling this function with an SPL of Zero (0) allows ALL Processes
- to be executed. This is considered the Standard action.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiSleep( Duration : WORD );
-
- [PARAMETERS]
-
- Duration Amount of Time to Sleep (in Milliseconds)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Functional equivalent of TP Delay, however this one allows for all MT
- actions to continue during the pause.
-
- Sleeps for "duration" milliseconds, allowing multi-procs to run.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiCriticalBEGIN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Begin a critical section. No multi-procs will run, interrupts will
- be disabled, windows ENTER CRITICAL SECTION will be will be called.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiCriticalEND;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Ends a critical section. Multi-proc can run, interrupts will be
- enabled, windows EXIT CRITICAL SECTION will be called.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiSetDVSPL( SPL : BYTE );
-
- [PARAMETERS]
-
- SPL Service Processing Level (7=Highest,0=Lowest)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Sets the System Priority Level for DesqView task switching.
- When VMultiDo is called with a priority >= this SPL,
- DesqView will be informed that another DV task should run.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiSetWinSPL( SPL : BYTE );
-
- [PARAMETERS]
-
- SPL Service Processing Level (7=Highest,0=Lowest)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Sets the System Priority Level for Windows task switching.
- When VMultiDo is called with a priority >= this SPL,
- windows will be informed that another windows task should run.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure VMultiSetOS2SPL( SPL : BYTE );
-
- [PARAMETERS]
-
- SPL Service Processing Level (7=Highest,0=Lowest)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Sets the System Priority Level for OS/2 task switching.
- When VMultiDo is called with a priority >= this SPL,
- Os/2 will be informed that another windows task should run.
-
- [SEE-ALSO]
-
- [EXAMPLE]
-
-