.MCALL .MODULE .MODULE SPTASK,VERSION=06,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL LC .NLIST BEX, CND ; ------------------------------------------------------------- ; ; This program is the main-line executive for the SPOOL ; package. It provides task scheduling and flow control. ; ; Author: Greg Adams ; ; Edit History: ; ; 25-AUG-83 GA Updated for RT-11 V5.1 ; 07-NOV-83 GA Rewrote for virtual overlaying. ; 03-Apr-88 RHH Multiple stream support ; 25-Dec-88 RHH .SCCA check ; 01-Nov-1990 JFW add COND comment block ;+ ;COND ; V$JOB (0) REL job ; 1 SAV (virtual) job ; ; SP$MLS (=V$JOB) stream(s) ; 0 1 stream ; 1 multiple streams ;- .IIF NDF V$JOB V$JOB =: 0 ; Build REL version by default SP$MLS =: V$JOB ; Multiple stream support ; ----- Macros and other definitions -------------------------- .MCALL .BR, .EXIT, .MRKT, .PRINT, .PVAL, .RSUM, .SPND, .UNLOCK .MACRO TASK NAME ; Define task control table entry. .GLOBL NAME .WORD 0,NAME .ENDM .MACRO ...... .ENDM ; ------ Task control table -------------------------------------- .PSECT .PURE.,D TSKTAB:: TASK CK.INT ; Task to check for SP INTEN enabled. TASK SDWTDN ; Task taken after output (to device) done. NUMTSK == .-TSKTAB/4 ; Number of tasks to check. MKTBLK: .BLKW 4. ; EMT parameter block for .MRKT calls TIME: .WORD 0,5. ; Sleep period for interrupt checking. IOTIME: .WORD 0,60. ; Sleep period for fake output done. .SBTTL SPTASK - SPOOL Task Scheduler .PSECT .CODE.,I .ENABL LSB ; ----- Spooler task scheduling ----------------------------------- SPTASK:: .IF EQ V$JOB MOV @#$SYPTR,R3 ; R3 -> Base of RMON. ADD #$SPSTA,R3 ; R3 -> Spooler status word. .IFF; EQ V$JOB .PVAL #AREA,#$SPSTA,#ACTIVE ; Declare SPOOL ACTIVE MOV #SPCSRV,R3 ; Get pointer to pseudo $SPSTA .ENDC; EQ V$JOB MOV R3,SPCSR ; Store the pointer. MOV #ACTIVE,@R3 ; Set the spooler as active. .UNLOCK ; Allow other jobs to use USR now. CALL TIMERO ; Do first MRKT to kick things off... ; The MAIN SPOOL loop... 10$: .SPND ; Wait for a completion routine to resume us. ; When here, a task scheduling event will ; have occured. TST CCAFLG ; is SPOOL being aborted by user? BEQ 20$ ; branch if not. JMP STOP ; Initiate rundown (in SPINT). ...... 20$: MOV #NUMTSK,R5 ; R5 = Number of tasks to check. MOV #TSKTAB,R4 ; R4 => Task control table. 30$: TST @R4 ; Is the task request count zero? BEQ 40$ ; Yes, then go select next task. DEC @R4 ; No, then mark it as being executed once CALL @2(R4) ; and go execute it. BR 20$ ; see if there's any more to do ...... 40$: ADD #4,R4 ; Move to next entry in task control table. DEC R5 ; Are all tasks checked? BGT 30$ ; No, go check another. BR 10$ ; Yes, then re-schedule. ...... .DSABL LSB .SBTTL TIMER routines ; ----- Force this to the root -------------------------------------- .PSECT .ROOT.,I,GBL,REL,CON TIMERO::.MRKT #MKTBLK,#TIME,#CR.TIM,#1 ; Start timer in motion. RETURN ...... ; ------------------------------------------------------------------- FAKEIO::.MRKT #MKTBLK,#IOTIME,#CR.FAK,R1 ; Start timer for fake output. RETURN ...... ; ------------------------------------------------------------------- .SBTTL CR.XXX - Completion Routines .ENABL LSB CR.TIM::MOV #CK.INT,R0 ; Here on mark time completion. BR ..CR.. ; Go schedule its associated task. ...... ; ------------------------------------------------------------------- .IF EQ SP$MLS CR.FAK::MOV R0,R1 ; fake output done, R0=device no. CR.DVD:: ; Here on device write done MOV #SDCTAB,R0 ; Add the base address of the table BIS #$CRPND,D.STAT(R0) ; Flag completion processing due .IFF; EQ SP$MLS CR.FAK:: ; fake output done, R0=device no. MOV R0,R1 ; get device number, BR 10$ ; go make ring entry ...... CR.DVD:: E0: MOV #0,R1 ; Entry for device 0 (must NOT be CLR) BR 10$ ...... E1: MOV #1,R1 ; Entry for device 1 BR 10$ ...... E2: MOV #2,R1 ; Entry for device 2 BR 10$ ...... E3: MOV #3,R1 ; Entry for device 3 BR 10$ ...... E4: MOV #4,R1 ; Entry for device 4 BR 10$ ...... E5: MOV #5,R1 ; Entry for device 5 BR 10$ ...... E6: MOV #6,R1 ; Entry for device 6 BR 10$ ...... E7: MOV #7,R1 ; Entry for device 7 10$: MOV #OIRING,R0 ; point to Output Input Ring Ptr MOVB R1,@0(R0) ; FIFO the completion request INC @R0 ; point to next ring location CMP @R0,#RINGMX ; beyond the end? BLOS 20$ ; branch if not MOV #ORING,@R0 ; reset input ring 20$: CLR R0 ; create index into device table 30$: DEC R1 ; reduce device number BLT 40$ ; until appropriate offset is found ADD #OT.ESZ,R0 BR 30$ ...... 40$: ADD #,R0 ; then add the base and status offset BISB #OTPND,@R0 ; Flag completion processing due. .ENDC; EQ SP$MLS DVDNSC: MOV #SDWTDN,R0 ; Now go schedule the processing task .BR ..CR.. ; Exit this completion routine .DSABL LSB .SBTTL ..CR.. - Completion Routine Finishup .ENABL LSB ..CR..: MOV #TSKTAB+2,R1 ; R1 => address of 1st task address. 10$: CMP R0,@R1 ; Is this the entry for this task? BEQ 20$ ; Yes, go schedule it to run. ADD #4,R1 ; No, then move to next entry BR 10$ ...... 20$: INC -(R1) ; Increment the task request count. 30$: .RSUM ; Resume main-line, it will dispatch. RETURN ...... .DSABL LSB .END