         << LINES .001/.009 ARE RESERVED FOR SYSTEMS INTEGRATION >>     00000001
<<=========================================================             00010000
=                                                         =             00015000
=                  INCLVMC - A1                           =             00020000
=                                                         =             00025000
=========================================================>>             00030000
                                                                        00035000
                                                                        00040000
$PAGE "VIRTUAL DISC SPACE MANAGEMENT : CHANGE STRING IN MAP"            00045000
PROCEDURE CHANGESTRINGINMAP(BITMAPABSBASE,STARTINGPAGE,LENGTH,          00050000
   OFFONFLAG);                                                          00055000
VALUE BITMAPABSBASE,STARTINGPAGE,LENGTH,OFFONFLAG;                      00060000
LOGICAL BITMAPABSBASE,STARTINGPAGE,LENGTH;                              00065000
LOGICAL OFFONFLAG;                                                      00070000
OPTION PRIVILEGED,UNCALLABLE;                                           00075000
                                                                        00080000
COMMENT                                                                 00085000
                                                                        00090000
TURNS A STRING OF LENGTH BITS ON OR OFF IN THE BIT MAP BEGINNING AT     00095000
ABSOLUTE LOCATION BITMAPABSBASE.  OFFONFLAG TRUE ==> TURN ON BITS.      00100000
                                                                        00105000
IF A BIT TO BE CHANGED IS FOUND ALREADY TO BE IN THE CHANGED STATE      00110000
A CONDITION CODE OF CCL IS RETURNED.  IF ALL OK, CC:=CCE.               00115000
                                                                        00120000
;                                                                       00125000
                                                                        00130000
BEGIN                                                                   00135000
EQUATE TSBCINSTRUCTION=%17400,                                          00140000
       TRBCINSTRUCTION=%17300;                                          00145000
                                                                        00150000
LOGICAL CURRENTWORDABSADDR,                                             00155000
        FIRSTBITINWORD,                                                 00160000
        BITSCHANGED;                                                    00165000
                                                                        00170000
LOGICAL CONDCODE:=CCE;                                                  00175000
                                                                        00180000
                                                                        00185000
CURRENTWORDABSADDR:=STARTINGPAGE&LSR(4)+BITMAPABSBASE;                  00190000
FIRSTBITINWORD:=STARTINGPAGE.(12:4);                                    00195000
BITSCHANGED:=0;                                                         00200000
                                                                        00205000
IF OFFONFLAG THEN TOS:=TSBCINSTRUCTION ELSE TOS:=TRBCINSTRUCTION;       00210000
                                                                        00215000
CHANGETHISWORD :                                                        00220000
                                                                        00225000
TOS:=ABSOLUTE(X:=CURRENTWORDABSADDR);                                   00230000
X:=FIRSTBITINWORD;                                                      00235000
WHILE X <= 15 AND BITSCHANGED < LENGTH DO                               00240000
   BEGIN                                                                00245000
   ASMB(XEQ 1);                                                         00250000
   <<BC>>                                                               00255000
   IF <> AND OFFONFLAG THEN CONDCODE:=CCL;                              00260000
   X:=X+1;                                                              00265000
   BITSCHANGED:=BITSCHANGED+1;                                          00270000
   END;                                                                 00275000
ABSOLUTE(CURRENTWORDABSADDR):=TOS;                                      00280000
IF BITSCHANGED < LENGTH THEN                                            00285000
   BEGIN                                                                00290000
   FIRSTBITINWORD:=0;                                                   00295000
   CURRENTWORDABSADDR:=CURRENTWORDABSADDR+1;                            00300000
   GO TO CHANGETHISWORD;                                                00305000
   END;                                                                 00310000
STATUS.CCFLD:=CONDCODE;                                                 00315000
END <<CHANGESTRINGINMAP>>;                                              00320000
                                                                        00325000
                                                                        00330000
$PAGE "VIRTUAL DISC SPACE MANAGEMENT : RELEASE SWAP REGION"             00335000
PROCEDURE RELEASESWAPREGION(DSTENTRYNUMBER);                            00340000
VALUE DSTENTRYNUMBER;                                                   00345000
LOGICAL DSTENTRYNUMBER;                                                 00350000
OPTION PRIVILEGED,UNCALLABLE;                                           00355000
                                                                        00360000
COMMENT                                                                 00365000
                                                                        00370000
RELEASES THE DISC DOMAIN ASSOCIATED WITH THE SWAPSEGMENT WHOSE          00375000
DST ENTRY NUMBER HAS BEEN PASSED AS CALLING PARAMETER BY SETTING        00380000
THE CORRESPONDING BITS IN THE DEVICE'S VIRTUAL DISC SPACE BITMAP.       00385000
                                                                        00390000
IF THE DISC ADDRESS IS BAD OR ONE OF THE BITS WAS ON, THE               00395000
CONDITION CODE IS SET TO CCL.  IF ALL OK, CC:=CCE.                      00400000
                                                                        00405000
;                                                                       00410000
                                                                        00415000
BEGIN                                                                   00420000
LOGICAL THISENTRYINDEX,                                                 00425000
        NUMBERTRIED,                                                    00430000
        ENTRYCOUNT,                                                     00435000
        NEXTENTRYINDEX,                                                 00440000
        VMPAGESALLOCATED,                                               00445000
        BITMAPABSBASE,                                                  00450000
        STARTINGPAGE;                                                   00455000
                                                                        00460000
DOUBLE DS1 = S-1;                                              <<06558>>00465000
DOUBLE SECTADDR;                                                        00470000
LOGICAL LDEV;                                                           00475000
                                                                        00480000
LOGICAL CONDCODE:=CCE;                                                  00485000
LOGICAL NOTTHISENTRY:=TRUE;                                             00490000
                                                                        00495000
PDISABLE;                                                               00500000
TOS:=DST(DSTENTRYNUMBER&LSL(2)+2);                                      00505000
LDEV:=LS0.(0:8);                                                        00510000
TOS:=TOS.(8:8);  <<HODA>>                                               00515000
TOS:=DST(X:=X+1);  <<LODA>>                                             00520000
SECTADDR:=TOS;                                                          00525000
VMPAGESALLOCATED:=DST(DSTENTRYNUMBER&LSL(2)+1).VMALLOC;                 00530000
                                                                        00535000
THISENTRYINDEX:=VDSMTAB(STARTENTRYINXWORD);                             00540000
ENTRYCOUNT:=VDSMTAB(VMSVOLUMECNTWORD);                                  00545000
NUMBERTRIED:=0;                                                         00550000
WHILE NUMBERTRIED <> ENTRYCOUNT AND NOTTHISENTRY DO                     00555000
   BEGIN                                                                00560000
   NUMBERTRIED:=NUMBERTRIED+1;                                          00565000
   IF VDSMTAB(THISENTRYINDEX+LDEVWORD) = LDEV THEN NOTTHISENTRY:=FALSE  00570000
   ELSE THISENTRYINDEX:=VDSMTAB(THISENTRYINDEX+NEXTINLISTWORD);         00575000
   END;                                                                 00580000
                                                                        00585000
IF VDSMTAB(THISENTRYINDEX+LDEVWORD) <> LDEV THEN CONDCODE:=CCL ELSE     00590000
   BEGIN <<FOUND VDSMTAB ENTRY FOR DEVICE>>                             00595000
   TOS:=SECTADDR;                                                       00600000
   TOS:=VDSMTAB(THISENTRYINDEX+HOSTARTSECTORWORD);                      00605000
   TOS:=VDSMTAB(THISENTRYINDEX+LOSTARTSECTORWORD);                      00610000
   ASMB(DSUB);                                                          00615000
   IF < THEN CONDCODE:=CCL ELSE                                         00620000
      BEGIN                                                             00625000
    STARTINGPAGE := INTEGER(DS1/DOUBLE(SECTORSPERVMPAGE));     <<06558>>00630000
      IF STARTINGPAGE+VMPAGESALLOCATED > VDSMTAB(THISENTRYINDEX+        00635000
         TOTALPAGESWORD) THEN CONDCODE:=CCL ELSE                        00640000
         BEGIN                                                          00645000
         BITMAPABSBASE:=SYSBASE+ABSOLUTE(SYSVDSMTAB)                    00650000
                        +THISENTRYINDEX+OFFSETTOVDSBITMAP;              00655000
         CHANGESTRINGINMAP(BITMAPABSBASE,STARTINGPAGE,VMPAGESALLOCATED, 00660000
            TURNON);                                                    00665000
         IF < THEN CONDCODE:=CCL ELSE                                   00670000
            BEGIN <<PAGES PROPERLY DEALLOCATED>>                        00675000
            X:=TOTALVMPAGESWORD;                                        00680000
            VDSMTAB(X):=VDSMTAB(X)+VMPAGESALLOCATED; <<GLOBAL CNT>>     00685000
            TOS:=VDSMTAB(THISENTRYINDEX+AVAILPAGESWORD);                00690000
            TOS:=TOS+VMPAGESALLOCATED;                                  00695000
            VDSMTAB(X):=LS0;                                            00700000
            VDSMTAB(THISENTRYINDEX+SMALLESTMISSWORD):=TOS;              00705000
            END;                                                        00710000
         END;                                                           00715000
      END;                                                              00720000
   END;                                                                 00725000
STATUS.CCFLD:=CONDCODE;                                                 00730000
PENABLE;                                                                00735000
END  <<RELEASESWAPREGION>>;                                             00740000
                                                                        00745000
                                                                        00750000
                                                                        00755000
                                                                        00760000
$PAGE "VIRTUAL DISC SPACE MANAGEMENT : GET SWAP REGION"                 00765000
DOUBLE PROCEDURE GETSWAPREGION(DSTENTRYNUMBER,NUMBEROFWORDS,LDEV);      00770000
VALUE DSTENTRYNUMBER,NUMBEROFWORDS,LDEV;                                00775000
LOGICAL DSTENTRYNUMBER,NUMBEROFWORDS,LDEV;                              00780000
OPTION PRIVILEGED,UNCALLABLE;                                           00785000
                                                                        00790000
BEGIN                                                                   00795000
                                                                        00800000
COMMENT                                                                 00805000
                                                                        00810000
GETSWAPREGION ALLOCATES A REGION OF VIRTUAL DISC SPACE FROM A           00815000
VIRTUAL MEMORY SUPPORTING (VMS) DEVICE.  THE CALLER HAS ACQUIRED AN     00820000
ENTRY FROM THE DST WHICH IS TO BE ASSOCIATED WITH THE SWAP REGION,      00825000
AND PASSES THIS ENTRY NUMBER, ALONG WITH THE NUMBER OF WORDS OF         00830000
SWAP REGION REQUIRED, AS CALLING PARAMETERS.  THE CALLER MAY ALSO       00835000
SPECIFY THE LDEV # ON WHICH THE DOMAIN IS TO RESIDE.                    00840000
                                                                        00845000
GETSWAPREGION CHECKS THE BITMAP OF THE AVAILABLE VIRTUAL MEMORY         00850000
SPACE ON THE SPECIFIED DEVICE OR ON THE NEXT DEVICE IN THE CIRCULAR     00855000
LIST OF VMS DEVICES FOR A SET OF CONTIGUOUS FREE PAGES WHICH WILL       00860000
SATISFY THE REQUEST.  IF NONE IS AVAILABLE AND NO DEVICE WAS            00865000
SPECIFIED, THE NEXT DEVICE IN THE LIST IS CHECKED.  IF THE REQUEST      00870000
CANNOT BE SATISFIED, 0D IS RETURNED.  OTHERWISE, THE LDEV # AND         00875000
DISC ADDRESS ARE RETURNED, AND THE NUMBER OF PAGES ALLOCATED FOR        00880000
THE DST IS RECORDED IN THE DST ENTRY WORD 1.                            00885000
                                                                        00890000
;                                                                       00895000
                                                                        00900000
LOGICAL GOTIT:=FALSE,                                                   00905000
        GIVEUP:=FALSE;                                                  00910000
                                                                        00915000
LOGICAL BITMAPABSBASE,                                                  00920000
        THISENTRYINX,                                                   00925000
        WORDINMAP,                                                      00930000
        TOTALWORDSINMAP,                                                00935000
        NUMBERTRIED,                                                    00940000
        ENTRYCOUNT,                                                     00945000
        BITINWORD,                                                      00950000
        THISDEVICENUMBER,                                               00955000
        STARTINGPAGE,                                                   00960000
        STRINGLENGTH,                                                   00965000
        SWAPPAGESREQ;                                                   00970000
                                                                        00975000
SUBROUTINE LOCATESTRINGOFONES;                                          00980000
                                                                        00985000
COMMENT                                                                 00990000
                                                                        00995000
SCANS THE BITMAP WHICH BEGINS AT ABSOLUTE CELL = BITMAPABSBASE          01000000
STARTING AT BIT 0 FOR A STRING OF SWAPPAGESREQ CONTIGUOUS BITS          01005000
WHICH ARE ON. IF SUCH A STRING IS FOUND, GOTIT IS SET                   01010000
TO TRUE, THE BITS ARE TURNED OFF, AND THE STARTING BIT NUMBER           01015000
OF THE FIRST ALLOCATED BIT IS RECORDED.                                 01020000
                                                                        01025000
;                                                                       01030000
                                                                        01035000
BEGIN                                                                   01040000
                                                                        01045000
GOTIT:=FALSE;                                                           01050000
WORDINMAP:=0;                                                           01055000
                                                                        01060000
TOS:=ABSOLUTE(BITMAPABSBASE+WORDINMAP);                                 01065000
                                                                        01070000
LOCATENEXTONBIT:                                                        01075000
                                                                        01080000
ASMB(TEST);                                                             01085000
WHILE = AND WORDINMAP < TOTALWORDSINMAP DO                              01090000
   BEGIN                                                                01095000
   WORDINMAP:=WORDINMAP+1;                                              01100000
   ASMB(DEL);                                                           01105000
   TOS:=ABSOLUTE(X:=BITMAPABSBASE+WORDINMAP);                           01110000
   END;                                                                 01115000
                                                                        01120000
IF WORDINMAP >= TOTALWORDSINMAP THEN ASMB(DEL) ELSE                     01125000
   BEGIN <<THIS WORD HAS SOME AVAILABLE PAGES>>                         01130000
   ASMB(SCAN);                                                          01135000
   STARTINGPAGE:=LOGICAL(X)+WORDINMAP&LSL(4);                           01140000
   STRINGLENGTH:=1;                                                     01145000
   BITINWORD:=X:=X+1;                                                   01150000
   TOS:=TOS&LSR(X);                                                     01155000
                                                                        01160000
   SCANONES :                                                           01165000
                                                                        01170000
   X:=BITINWORD;                                                        01175000
   ASMB(TRBC 0,X);                                                      01180000
   WHILE <> AND STRINGLENGTH < SWAPPAGESREQ AND X <= 15                 01185000
   DO                                                                   01190000
      BEGIN                                                             01195000
      STRINGLENGTH:=STRINGLENGTH+1;                                     01200000
      X:=X+1;                                                           01205000
      ASMB(TRBC 0,X);                                                   01210000
      END;                                                              01215000
   IF STRINGLENGTH = SWAPPAGESREQ THEN                                  01220000
      BEGIN                                                             01225000
      ASMB(DEL);                                                        01230000
      CHANGESTRINGINMAP(BITMAPABSBASE,STARTINGPAGE,SWAPPAGESREQ,        01235000
        TURNOFF);                                                       01240000
IF <> THEN SUDDENDEATH(632);                                   <<04293>>01245000
      GOTIT:=TRUE;                                                      01250000
      END                                                               01255000
   ELSE IF X<>16 OR ABSOLUTE(BITMAPABSBASE+WORDINMAP).(15:1)<>1         01260000
   THEN GO LOCATENEXTONBIT <<HIT END OF STRING>> ELSE                   01265000
      BEGIN  <<END OF WORD>>                                            01270000
      ASMB(DEL);                                                        01275000
      WORDINMAP:=WORDINMAP+1;                                           01280000
      IF WORDINMAP < TOTALWORDSINMAP THEN                               01285000
         BEGIN <<CONTINUE SCAN>>                                        01290000
         TOS:=ABSOLUTE(BITMAPABSBASE+WORDINMAP);                        01295000
         BITINWORD:=0;                                                  01300000
         GO TO SCANONES;                                                01305000
         END;                                                           01310000
      END;                                                              01315000
   END;                                                                 01320000
END <<SUBROUTINE LOCATESTRINGOFONES>>;                                  01325000
                                                                        01330000
PDISABLE;                                                               01335000
                                                                        01340000
SWAPPAGESREQ:=(NUMBEROFWORDS-1)/VMPAGESIZE+1;                           01345000
ENTRYCOUNT:=VDSMTAB(VMSVOLUMECNTWORD);                                  01350000
THISENTRYINX:=VDSMTAB(STARTENTRYINXWORD);                               01355000
NUMBERTRIED:=0;                                                         01360000
DO                                                                      01365000
   BEGIN <<TRY TO GET A REGION OF SUFFICIENT SIZE OFF THIS DEVICE>>     01370000
   NUMBERTRIED:=NUMBERTRIED+1;                                          01375000
   THISDEVICENUMBER:=VDSMTAB(THISENTRYINX+LDEVWORD);                    01380000
   IF LDEV <> 0 AND LDEV <> THISDEVICENUMBER THEN                       01385000
      BEGIN <<SKIP THIS ENTRY>>                                         01390000
      IF NUMBERTRIED=ENTRYCOUNT THEN GIVEUP:=TRUE                       01395000
      ELSE THISENTRYINX:=VDSMTAB(THISENTRYINX+NEXTINLISTWORD);          01400000
      END                                                               01405000
   ELSE                                                                 01410000
      BEGIN                                                             01415000
      IF VDSMTAB(THISENTRYINX+AVAILPAGESWORD) < SWAPPAGESREQ            01420000
      OR VDSMTAB(THISENTRYINX+SMALLESTMISSWORD) <= SWAPPAGESREQ THEN    01425000
         BEGIN <<THIS DEVICE IS NO GOOD>>                               01430000
         THISENTRYINX:=VDSMTAB(THISENTRYINX+NEXTINLISTWORD);            01435000
         IF LDEV <> 0 AND LDEV = THISDEVICENUMBER THEN GIVEUP:=TRUE;    01440000
         END                                                            01445000
      ELSE                                                              01450000
         BEGIN <<GOT A CHANCE WITH THIS DEVICE>>                        01455000
         BITMAPABSBASE:=ABSOLUTE(SYSVDSMTAB)+SYSBASE                    01460000
            +THISENTRYINX+OFFSETTOVDSBITMAP;                            01465000
         TOTALWORDSINMAP:=VDSMTAB(THISENTRYINX+WORDSINBITMAPWORD);      01470000
         LOCATESTRINGOFONES;                                            01475000
         IF NOT GOTIT THEN                                              01480000
            BEGIN <<FAILED>>                                            01485000
            VDSMTAB(THISENTRYINX+SMALLESTMISSWORD):=SWAPPAGESREQ;       01490000
            THISENTRYINX:=VDSMTAB(THISENTRYINX+NEXTINLISTWORD); <<NEXT>>01495000
            END;                                                        01500000
         END;                                                           01505000
      END;                                                              01510000
   END                                                                  01515000
UNTIL GIVEUP OR GOTIT OR NUMBERTRIED=ENTRYCOUNT;                        01520000
                                                                        01525000
IF GOTIT THEN                                                           01530000
   BEGIN <<SUCCESSFULLY ALLOCATED A SWAP DOMAIN>>                       01535000
                                                                        01540000
   <<UPDATE NUMBER OF PAGES AVAILABLE GLOBALLY AND ON DEVICE>>          01545000
                                                                        01550000
   VDSMTAB(TOTALVMPAGESWORD):=VDSMTAB(TOTALVMPAGESWORD)-SWAPPAGESREQ;   01555000
   IF VDSMTAB(TOTALVMPAGESWORD) < VDSMTAB(GLOBLEASTAVAILPAGESWORD)      01560000
   THEN VDSMTAB(GLOBLEASTAVAILPAGESWORD):=VDSMTAB(TOTALVMPAGESWORD);    01565000
   X:=THISENTRYINX+AVAILPAGESWORD;                                      01570000
   VDSMTAB(X):=VDSMTAB(X)-SWAPPAGESREQ;                                 01575000
IF < THEN SUDDENDEATH(632);                                    <<04293>>01580000
   IF VDSMTAB(THISENTRYINX+AVAILPAGESWORD) < VDSMTAB(THISENTRYINX+      01585000
   DEVLEASTAVAILPAGESWORD)                                     <<JB.19>>01590000
   THEN VDSMTAB(THISENTRYINX+DEVLEASTAVAILPAGESWORD)           <<JB.19>>01595000
      :=VDSMTAB(THISENTRYINX+AVAILPAGESWORD);                           01600000
                                                                        01605000
   <<ADVANCE THE CYCLIC POINTER FOR VM DEVICE SELECTION>>               01610000
                                                                        01615000
   VDSMTAB(STARTENTRYINXWORD):=VDSMTAB(THISENTRYINX+NEXTINLISTWORD);    01620000
                                                                        01625000
   <<CALCULATE AND RETURN DISC ADDRESS>>                                01630000
                                                                        01635000
   TOS:=VDSMTAB(THISENTRYINX+HOSTARTSECTORWORD);                        01640000
   TOS:=VDSMTAB(THISENTRYINX+LOSTARTSECTORWORD);                        01645000
   TOS:=0;                                                              01650000
   TOS:=STARTINGPAGE;                                                   01655000
   TOS:=0;                                                              01660000
   TOS:=SECTORSPERVMPAGE;                                               01665000
   ASMB(DMUL;DADD); <<STARTING SECTOR>>                                 01670000
   LS1.(0:8):=THISDEVICENUMBER;                                         01675000
   GETSWAPREGION:=TOS;                                                  01680000
   DST(DSTENTRYNUMBER&LSL(2)+1).VMALLOC:=SWAPPAGESREQ;                  01685000
   END                                                                  01690000
ELSE GETSWAPREGION:=0D;                                                 01695000
PENABLE;                                                                01700000
END  <<GETSWAPREGION>>;                                                 01705000
                                                                        01710000
                                                                        01715000
<<=========================================================             01720000
=                                                         =             01725000
=                  END INCLVMC                            =             01730000
=                                                         =             01735000
=========================================================>>             01740000
