*
*
*M*      SACT      SYMBIONT ACTIVATION MODULE(SYMB  CNTXT INIT)
*
*P*      NAME:     SACT
*,*
*,*      PURPOSE:            SACT IS THE PACKAGE CONTAINING SYMBIONT
*,*           SCHEDULING QUEUE MANAGEMENT, SYMBIONT CONTEXT INITIALIZATION
*,*           AND THE SYMBIONT CONTEXT BLOCK DEFINITION.
*,*           SACT IS ALWAYS ENTERED UNMAPPED FROM I/O INTERRUPT
*,*           PROCESSING AFTER I/O END-ACTION OR FROM THE SYSTEM
*,*           IDLE LOOP.
*,*
*,*
*,*      METHOD:             SACT IMMEDITAELY EXITS IF NO SYMBIONTS ARE
*,*           QUEUED, OTHERWISE IT PROCESSES IN ORDER THE SYMBIONT
*,*           ACTIVATION QUEUE, CORE QUEUE AND DISC QUEUE.  A QUEUE
*,*           HEAD IS FETCHED AND CLEARED ONCE PER SACT ENTRY ALLOWING A
*,*           SYMBIONT ENTERED FROM A QUEUE TO REQUEUE ON THE SAME OR A
*,*           HIGHER QUEUE WITHOUT CAUSING SACT TO LOOP.  THUS AN ENTRY
*,*           TO SACT CAUSES EXACTLY ONE ROUND-ROBIN OF QUEUED SYMBIONTS
*,*           THEN CONTROL IS RETURNED TO THE SYSTEM.  THIS ALSO MAKES
*,*           SACT REENTRANT IN THE SENSE THAT THE SACT ENTRY THAT GRABS
*,*           A QUEUE WILL PROCESS THE QUEUE AT THAT ENTRY LEVEL
*,*           REGARDLESS OF HOW MANY LATER RE-ENTRIES ARE MADE.  THE
*,*           CORE QUEUE IS ONLY RUN IF SYSTEM PARAMETERS ALLOW
*,*           SYMBIONTS TO STEAL NEEDED CORE.  ACTIVATE QUEUE SYMBIONTS
*,*           ARE ENTERED IF THEIR SSTAT IS 1 OR IF THEY HAVE A CONTEXT B
*,*           BLOCK.  OTHERWISE THEY ARE GIVEN AN INITIALIZED CONTEXT
*,*           BLOCK IF POSSIBLE THEN ENTERED.  IF NO CONTEXT BLOCKS ARE
*,*           AVAILABLE THE SYMBIONT IS REQUEUED.  SACT MODULE DETAIL
*,*           COMMENTARY DESCRIBES THE SYMBIONT CONTEXT BLOCK AND THE
*,*           SYMBIONT CORE QUEUE CALCULATION.
*,*
*,*      REFERENCE:          MODULE OUTSYM FOR SYMBIONT INFO, MODULE
*,*           SYMSUBR FOR SYMBIONT QUEUEING, MODULES MM AND REQDC FOR SYMBIONT
*,*           BUFFER MEMORY HANDLING.
*,*
*,*
         DEF      SACT:             * MODULE BASE DEFED FOR XDELTA PATCHING
SACT:    EQU      %
*        D00 RJR   19:35  10/24/72.
*    ##   ONE MORE TIME   11:00 05/05/72  RJR *
*     FINAL I HOPE  ##     16:00  04/24/72 RJR *
*                     19:40  03/22/72  *
* #SACT#              09:45  11/15/71  *
*                 CATALOG NO. 704930 - SIGMA 5/7 BPM M:SACT
         SYSTEM   UTS
         DEF      SACT              * MODULE NAME AND MAIN ENTRY(SYMBIONT ACTIVA
SACT     EQU      %
*
*                 SYMBOLIC REGISTER DEFINITIONS.
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
         PAGE
*QUEUED SYMBIONT ACTIVATE ROUTINE,SEMI-REENTRANT
*ENTERED FROM I/O INTERRUPT CODE AFTER END ACTION RETURN
*SR1,SR2,AND SR3 VOLATILE
*        BAL,SR4  SACT
         REF      SQHD              * SYMB QUE HEAD(DATA CELL: DISC Q,CORE Q,
*,*                                 * ACTIVATE Q,0 8,8,8,8)
         REF      SQUE              * SYMB QUE CHAIN (DATA) HEAD IS SQHD
*,*                                 * TAIL IS SQTL,CONTAINS NEXT SYMB ON CHAIN
         REF      SQTL              * SYMB QUE TAIL(DATA CELL:DISC,CORE,ACTVT,0)
*,*                                 * 8,8,8,8 SYMTABX OF LAST SYMB ON CHAIN
         REF      SCNTXT            * HW TABLE OF SYMB CNTXT DW ADDR'S
*,*                                 * 0=>SYMB HAS NO CNTXT:SET ONLY BY SACT
         REF      SRET              * SYMB RETURN ADDR(WORD DATA TABLE)
         REF      GSC               * GET SYMBIONT CNTXT BLK ROUTINE(FROM CPOOL)
         REF      SYMX              * SYMB FLAG TABLE(BYTE SET BY KEYN,SYSGEN)
         REF      SAQNSERT          * SYMB ACTIVATE QUEUE INSERT ROUTINE
*,*                                 * CHAINS (R3) SYMB ON ACTIVATE QUE(SQUE)
         REF      SNDDX             * SYMB 'NDD' INDEX BYTE TABLE(DCT INDEX)
*,*                                 * 1ST MXSTRM NTRIES DATA(OTHERS NOT CHGD)
         REF      S:STLC            * STEALER WIND DOWN FLAG(NEG MEANS WNDDWN)
         REF      SPOOL             * FREE SYMB CORE BUFF HEAD
         REF      SL:RSVP           * THEFT RESERVATION #PGES
         REF      S:STL#            * OVER STOLEN COUNT #PGES
*
         SREF     OCPFEA            * X1200 HANDLER SYMB FILE END
*,*                                 * ACTION ROUTINE(ADDR SET IN CNTXT)
         SREF     OCPDVEA           * X1200 HANDLER SYMB DEV END ACTION
*SPRC=(66*134/(SBSIZE-1)*4+1)*SBSECTS/SGSIZE                            930
SYMCQ    EQU      1                                                     930
         LW,R0    SQHD              SYMBIONT IN QUEUE
         BEZ      *SR4              NO,EXIT
         PUSH     SR4               YES,SAVE EXIT
         LI,R2    2                 INITIALIZE SYMBIONT QUEUE HEAD INDEX
SACT00   EQU      %                                                     930
         CI,R2    SYMCQ             SYMBIONT CORE QUEUE INDEX           930
         BNE      SACT00A           NO                                  930
*                                   YES, BUT
         LW,R0    S:STLC            * WINDING DOWN
         BLEZ     SACT01B           * YES, CANT GIVE CORE
         LW,R1    SPOOL             * NO, IS FREE POOL NON-EMPTY
         BGZ      SACT00A           * THEN QUIT FOOLING AROUND.
         AW,R0    SL:RSVP           * MT FREPOOL BUT CAN WE
         SW,R0    S:STL#            * STEAL TOO EXPAND IT
         BLEZ     SACT01B           * NO, CANT EVEN SWIPE.
*                                   * YES, GUY FROM CORE QUEUE
*                                   * WILL CAUSE THEFT.
*        NOTE: DISABLE HERE WONT HELP THEFT WINDOWS.
*
SACT00A  LI,R0    0                 NO,ZERO INDEX                       930
         DISABLE                    PRENT INTERRUPTS                    930
         LB,R1    SQHD,R2           INDEX IN SYMBIONT QUEUE HEAD        930
         STB,R0   SQTL,R2           INSERT IN SYMBIONT QUEUE TAIL
         STB,R0   SQHD,R2           INSERT INDEX IN SYMBIONT QUEUE HEAD
         ENABLE                     ALLOW INTERRUPTS
         STB,R1   R2                QUEUE CHAIN HEAD                    930
SACT01   LB,R3    R2                SYMBIONT IN QUEUE CHAIN             930
         BNEZ     SACT01A           YES                                 930
SACT01B  AI,R2    -1                NO,DECREMENT HEAD INDEX             930
         BGEZ     SACT00            LOOP IF MORE QUEUE CHAINS TO CHECK
         PULL     SR4               RESTORE EXIT
         B        *SR4              EXIT
SACT01A  LB,R1    SQUE,R3           NEXT SYMBIONT INDEX                 930
         STB,R1   R2                TO QUEUE CHAIN HEAD                 930
         PUSH     R2                SAVE QUEUE HEAD INDEX
         LI,R0    0                 ZERO INDEX                          930
         STB,R0   SQUE,R3           TO REMOVED SYMBIONT QUEUE INDEX     930
         PAGE
*
*SYMBIONT IN QUEUE
*
SACT02A  EQU      %                 NO
         LH,SR3   SCNTXT,R3         SYMBIONT CONTEXT BLOCK ADDRESS
         BEZ      SACT03            NONE - GO GET ONE AND SETUP
         SLS,SR3  1                 CONTEXT BLOCK WORD ADDRESS
         LW,R4    *SR3              SYMBIONT BASE ADDRESS
         LW,R1    SR3
         LW,R2    SRET,R3           SYMBIONT RETURN ADDRESS
         LI,SR4   SACT02B           SYMBIONT EXIT
         PUSH     SR4               TO TEMP STACK
         B        0,R2              ENTER SYMBIONT
SACT02B  PULL     R2                RESTORE QUEUE HEAD INDEX
         B        SACT01            LOOP
         PAGE
*
*SYMBIONT TO BE ACTIVATED/DEACTIVATED
*I,X,L,C,R SIGNAL CHARACTER
SACT03   EQU      %
         BAL,SR4  GSC               CONTEXT BLOCK
         BEZ      SACT07            NO
         LB,SR4   STB:TYP,R3
         B        SACT03A
DSCFQARGS GEN,8,8,8,8 0,SCFQPRI,10,0
DSCDQARGS GEN,8,8,8,8  0,X'FF',3,0
         DEF      SYMTRAN           * SYMB OLD TO NEWQ FUNCT CODE XLATE
SYMTRAN  EQU      %
DSCDQFCLP GEN,8,8,8,8  3,3,3,3
         GEN,8,8,8,8 1,1,3,3
DSCDQFCCP GEN,8,8,8,8  0,0,1,1
          GEN,8,8,8,8  0,0,1,1
*
SACT03A  EQU      %
         LI,R0    0
         LI,R2    CBSIZE-1
         STW,R0   *D3,R2
         BDR,R2   %-1
         LB,R2    SYMX,R3
         CI,R2    1   'CR'
         BANZ     SACT04
         LW,R2    D3
         LW,R0    DSCFQARGS
         STW,R0   SCFQARGS,R2
         LI,R0    SBSIZE
         SLS,R0   2
         STW,R0   SCBSIZ,R2
         LB,R0    SNDDX,R3
         AW,R0    DSCDQARGS
         STW,R0   SCDQARGS,R2
         STW,R3   SCDCDA,R2
         LI,R0    OSFEA             ***********NOT RE-LOCATABLE****
         LI,R4    OSDEA
         LC       SYMX,R3
         BCR,2    SACT03B
         LI,R0    OCPFEA            ITS AN OCP GET ENDACTION
         LI,R4    OCPDVEA           ADRESSES FOR OCP
SACT03B  EQU      %
         STW,R0   SCFEA,R2          FILE END ACTION ADDRESS
         STW,R4   SCDEA,R2          DEVICE ENDACTION ADDRESS
SACT04   LW,1     14
         STW,11   SCDEVTYP,1
         LB,R2    SYMX,R3
         AND,R2   M2
*SYMBIONT IN CORE AND IN USE
*SET UP SYMTAB AND CONTEXT BLOCK
*(R2) = WORD INDEX TO ADR OF SYMBIONT IN S1TB
*(R3)=SYMTAB INDEX
*(D3)=CONTEXT BLOCK ADDRESS
         LW,R0    S1TB,R2           SYMBIONT BEING LOADED
         STW,R0   SRET,R3
         STB,R3   R0                SYMTAB INDEX,SYMBIONT BASE ADDRESS
         STW,R0   *D3               TO CONTEXT BLOCK
         SLS,D3   -1                CNTXT BLK DOUBLE WORD ADDRESS
         STH,D3   SCNTXT,R3         TO SYMBIONT TABLE
         B        SACT02A           GO TO ENTER SYMBIONT
*
*NO CONTEXT BLOCK AVAILABLE
SACT07   EQU      %
         LI,SR4   SACT02B           EXIT ADDRESS
         B        SAQNSERT          QUEUE UP SYMBIONT
         PAGE
*
*  THIS IS A DUMMY S1TB TABLE.  INCLUDED TEMPORARILY UNTIL SYMBIONTS
*  ARE RE-CODED FOR STRUNG OUT UTM WHEN S1TB WONT BE REFERENCED
*  SYMX MUST CONTAIN INDECES 1 FOR CR, 2 FOR CP, LP
*
         REF      SYMCR             * INSYM ROUTINE ENTRY(AND BASE)FOR CNTXT
         REF      SYMPPRTY          * OUTSYM ROUTINE ENTRY(AND BASE)FOR CNTXT
S1TB     EQU      %
         DATA     SC2D3             *ZERO ENTRRY
*                                   *SOMETHINGS WRONG WITH SYMX
         DATA     SYMCR
         DATA     SYMPPRTY
         DATA     SC2D3             SPILL-FILL ENTRY, NOT IMPLEMENTED
SC2D3    SCREECH  X'2D',3           NEVER HAPPENS.....HERE....
         PAGE
         REF      OSDEA           *OUTSYM DEVICE END ACTION ROUTINE
         REF      OSFEA           *OUTSYM FILE   END ACTION ROUTINE
         REF      STB:TYP         *STREAM DEVICE TYPE BYTE TABLE
         REF      M2              *=X'00000003' IN/OUT MASK FOR SYMX
*                                 *
         DEF      SBSIZE          * SYMBIONT BLOCK SIZE VALUE
         DEF      CBSIZE          * CONTEXT BLOCK SIZE VALUE
         DEF      SCFQPRI * CNTXT DISP FILE NEWQ ARGS (IO PRIO)
SCFQPRI  EQU      X'FA'             *
SBSIZE   EQU      256               *HALF GRAN SYMB BLOCKS
CBSIZE   EQU      32                *16 CNTXT BLKS PER PAGE
         DEF      SCFLDA          * CONTEXT DISP FLINK DISC ADDRESS
         DEF      SCBLDA          * CNTXT DISP BLINK DISC ADDRESS
         DEF      SCFQARGS        * CNTXT DISP FILE NEWQ ARGUMENTS
         DEF      SCFBUF          * CNTXT DISP FILE BUFFER ADDRESS
         DEF      SCBSIZ          * CNTXT DISP BLOCK SIZE
         DEF      SCCDA           * CNTXT DISP CURRENT DISC ADDRESS
         DEF      SCDQARGS        * CNTXT DISP DEVICE NEWQ ARGUMENTS
         DEF      SCDDBI          * CNTXT DISP DEVICE DATA BYTE INDEX
         DEF      SCDBC           * CNTXT DISP DEVICE BYTE COUNT
         DEF      SCDCDA          * CNTXT DISP DEVICE CURRENT DISC ADDRESS
         DEF      SCTYC           * CNTXT DISP TYPE OF IO COMPLETE
         DEF      SCBUPPT         * CNTXT DISP BACK UP POINT
         DEF      SCNCBT          * CNTXT DISP NO COMM BUFF TEMP AREA(4WRDS)
         DEF      SCBUPPTS        * CNTXT DISP BACK UP POINT SAVE
         DEF      SCDQFC          * CNTXT DISP DEVICE NEWQ FUNC CODE XLATE TABLE
         DEF      SCDEVTYP        * CNTXT DISP DEVICE TYPE
         DEF      SCFCO           * CNTXT DISP FILE COUNT
         DEF      SCTOFDA         * CNTXT DISP TOP OF FORM DISC ADDRESS
         DEF      SCXTRAB         * CNTXT DISP EXTRA BUFFER LIST
         DEF      SCRCVLST        * CNTXT DISP RECOVERY LIST
         DEF      SCDALST         *  CNTXT DISP(OUTSYM) PRINT RCVRY LIST
         DEF      SCBUDA         * CNTXT DISP(OUTSYM) BACKUP RCVRY D.A.
         DEF      SCLINES         * CNTXT DISP LINE COUNT
         DEF      SCDINFO         * CNTXT DISP DEVICE INFORMATION
         DEF      SCBESTDA        * CNTXT DISP BEST DISC ADDRESS('Q')
         DEF      SCSVDGI         * CNTXT DISP SAVED GHOST INFORMATION
*                                 *
         DEF      SCDBI           * CNTXT DISP DATA BYTE INDEX
         DEF      SCMINR          * CNTXT DISP MINIMUM RECORD SIZE
         DEF      SCMAXR          * CNTXT DISP MAXIMUM RECORD SIZE
         DEF      SCMISC          * CNTXT DISP MISCELLANEOUS
         DEF      SCSEQ           * CNTXT DISP SEQUENCE INFO
         DEF      SCFPC           * CNTXT DISP FORM PROJECTOR CONTROL
         DEF      SCFORM          * CNTXT DISP FORM NAME
         DEF      SCFFORM         * CNTXT DISP FUTURE FORM NAME
         DEF      SCGCO           * CNTXT DISP GRANULE COUNT
         DEF      SCRCO           * CNTXT DISP RECORD COUNT
         DEF      SCPCO           * CNTXT DISP PAGE COUNT
         DEF      SCCUN           * CNTXT DISP CURRENT USER NUMBER
         DEF      SCRPDA          * CNTXT DISP RELEASE PREVIOUS DISC ADDRESS
         DEF      SCFINFLG        * CNTXT DISP (INSYM)  FIN FLAG
         DEF      SCMODE          * CNTXT DISP (INSYM)  BLKING MODE
         DEF      SCAIF           * CNTXT DISP (INSYM) ADD IN FIL FLG
         DEF      SCJCO           * CNTXT DISP (INSYM)  JOB COUNT
         DEF      SCSYMX          * CNTXT DISP (INSYM)  SYMX(SYMTABX)
         DEF      SCSWIT          *  CNTXT DISP IO SWITCH
         DEF      SCDEA           *  CNTXT DISP DEVICE END AC
         DEF      SCFEA           *  CNTXT DISP FILE END AC
         DEF      SCCOMFLG          * FLAGS FOR CONCURRENT OUTPUT MODE
         DEF      SCCOMID           * CONCURRENT OUTPUT MODE ID
*        CDISP    SDEF
SDEF     CNAME    0
         OPEN     #
#         SET     0
*
         PROC
         GOTO,SCOR(CF(2),ORG,RES)  ORG,RES
I        DO       NUM(LF)
J        DO       NUM(LF(I))
LF(I,J)  EQU      #
         FIN      J
         DISP     (#/10)**28+(#-((#/10)*10))**24+#+I**16
#        SET      #+(1&(AF(I,1)=0))|AF(I,1)
         FIN      I
         GOTO     %PEND
*
ORG      SET      %
#        SET      AF(1)
         GOTO     %PEND
*
RES      SET      %
#        SET      #+AF(1)
%PEND    BOUND    1
         ERROR,,#>CBSIZE  ' DEFINITION EXCEEDS CBSIZE'
         PEND
*
         CLOSE    #
*
*
SCBNO    SDEF
SCDEVTYP SDEF
SCFLDA   SDEF
SCBLDA   SDEF
SCBESTDA SDEF
SCFQARGS,SCFBUF,SCBSIZ,SCCDA,SCFEA SDEF
SCDQARGS,(SCDDBI,SCDBI),SCDBC,SCDCDA,SCDEA SDEF
(SCSVDGI,SCAIF) SDEF
(SCTYC,SCDINFO,SCMINR),;
   (SCSWIT,SCDQFC,SCMAXR)   SDEF
*       -- NOTE:  SCDINFO IS FIVE WORDS FOR INSYM --
(SCMISC,SCTOFDA),SCSEQ           SDEF
(SCCOMID,SCFCO,SCJCO,SCBUPPT),(SCGCO,SCMODE)             SDEF
(SCRCO,SCBUPPTS),SCPCO                   SDEF
(SCGCNT,SCFPC),(SCNCBT,SCFORM,SCRTRY),(SCBUDA,SCDALST,SCFFORM),;
  SCRPDA SDEF
(SCRCVLST,SCFINFLG)    SDEF
(SCXTRAB,SCCUN,SCSYMX)  SDEF
(SCLINES,SCNAME)   SDEF
SCCOMFLG          SDEF
         DEF      SCNAME            * CNTXT DISP FORM NAME OF STRM
*,*                                 ~
         DEF      SCGCNT            * CNTXT DISP GRANULE COUNT OF STRM FILE
*,*                                 ~
         DEF      SCRTRY            * CNTXT DISP TO RETRY COUNT(BAD DISC)
*
         DEF      SCDALSZ           * CNTXT VALUE DISC ADDR LIST SIZE
SCDALSZ  EQU      40-SCDALST        FOR 40 WORD CPOOL
         PAGE
*
*        SGC FAMILY OF SERVICE ROUTINES MOVED TO COOP
*
*                 TO ALLOW THE MONITOR TO FLOAT IN SIZE
*               ABOVE THE .8000 BOUNDARY IMPLIED BY THE
*               NEED TO HAVE MAPPED SERVICE ROUTINES EXIST
*               1-TO-1 WITH THE USER, ALL MAPPED SERVICE
*               ROUTINES NOW EXIST IN TOTALLY MAPPED SERVICE
*               MODULES,AND UNMAPPED(INTURRUPT) ROUTINES
*               EXIST IN SEPERATE MODULES THAT ARE
*               LOCCT'ED TO THE ROOT TOP AND MAY EXTEND
*               BEYOND .8000 .
*
*
*
         END

