Text preview for : BFS.mesa_Oct77.pdf part of xerox BFS.mesa Oct77 xerox mesa 3.0_1977 listing BFS.mesa_Oct77.pdf
Back to : BFS.mesa_Oct77.pdf | Home
brs.mesa 24-0CT-77 21:16:31 Page 1
-- BFS.Mesa Edited by Sandman on August 23, 1977 9:47 PM
DIRECTORY
AltoDers: FROM "altodefs",
AltoFileDers: FROM "altofiledefs",
BFSDefs: FROM "bfsdefs",
DiskDefs: FROM "diskdefS"'
DiskKDDefs: FROM "diskkddefs",
InlineDefs: FROM "inlinedefs",
MiseDers: FROM "miscdefs",
SegmentDefs: FROM "segmentdefs",
StringDefs: FROM "stringdefs";
DEFINITIONS FROM AltoDefs, AltoFileDefs, DiskDefs;
BFS: PROGRAM
IMPORTS DiskDefs, D1skKDDefs, MiseDers, SegmentDefS' StringDefs
EXPORTS BFSDefS = BEGIN
-- These should be POINTER TO ARRAY OF ...
CAvee: TYPE = DESCRIPTOR FOR ARRAY OF POINTER;
DAvee: TYPE = DESCRIPTOR FOR ARRAY OF vDA:
AetOnPages: PUBLIC PROCEDURE [arg:POINTER TO update DiskRequest]
RETURNS [page:PageNumber, bytes:CARDINAl] =
BEGIN OPEN arg, DiskDefs; a: vDC; dde: DOC:
i: PageNumber; eb, nexteb: CBptr;
ebzone: ARRAY [0 .. lCBZ) OF UNSPECIFIED;
zone: CBZptr = @cbzone[O]:
CAs: CAvee = DESCRIPTOR[ea,lastPage+l];
DAs: DAvee = DESCRIPTOR[da,lastPage+2];
InitializeCBstorage[zone,nCB,firstPage,elear];
zone. info ~ da; zone.eleanup ~ cleanup;
BEGIN ENABLE RetryableDiskError =) RETRY:
eb ~ GetCB[zone,elear I ANY =) ERROR]:
FOR i ~ zone.eurrenLPage, 1+1 UNTIL i=lastPage+1 DO
BEGIN -- inner compound to skip DoNothing pages
a ~ IF i=lastPage THEN lastAetion ELSE action;
IF a = DoNothing THEN GOTO SkipThisPage;
IF DAs[i] = eofDA THEN EXIT:
IF signalCheckError AND zone.errorCount = RetryCount/2
THEN SIGNAL DiskCheckError[i];
nexteb ~ GetCB[zone,clear];
cb. labelAddress ~ IF DAs[i+l] = fillinDA
THEN lOOPHOlE[@nexteb.header.diskAddress]
ELSE @nextcb.label:
dde ~ DDC [
eb,IF fixedCA THEN ea ELSE CAs[i],DAs[i],i,fp,FAlSE,a];
DoDiskCommand[@dde]:
eb ~ nexteb;
EXITS
SkipThisPage =) NUll;
END:
ENDlOOP;
CleanupCBqueue[zone];
END; -- of enable bloek
RETURN[i-1,zone.eurrentBytes]
END:
GetNextDA: PUBLIC PROCEDURE [eb:CBptr] =
BEGIN
pn: PageNumber = eb.page;
DAs: DAvee = DESCRIPTOR[cb.Lone.info,pn+2];
Ir DAs[pn+l] = fillinDA TH[N
DA~[pn+1] ~ VirtualDA[cb.labelAddress.next];
rr DAs[pn-t] = fillinDA THrN
DAs[pn-1] ~ VirtualDA[cb. labelAddress.prev];
RETURN
[NO;
bfs.mesa 24-0CT-77 21:15:31 Page Z
-- Currently OiskRequest.aetion is not used by WritePages (WriteO is assumed).
-- Note also that lastAetion is used only if lastPage isn't being rewritten.
WritePages: PUBLIC PROCEOURE [arg:POINTER TO extend DiskRequest]
RETURNS [page:PageNumber, bytes:CAROINAl] = BEGIN
aop: update DiskRequest:
firstNewPage: PageNumber:
local: extend OiskRequest ~ argt:
DAs: OAvee = OESCRIPTOR[arg.da,arg.lastPage+2]:
BEGIN OPEN local:
IF DAs[firstPage] = fillinDA THEN firstNewPage ~ firstPage
ELSE BEGIN
aop ~ DiskRequest [
ea, da, firstPage, lastPage, fp, fixedCA, WriteO,
lastAetion, signalCheekError, update[GetNextDA]]:
[page,bytes] ~ Aet0nPages[@aop]:
IF (firstPage ~ page) = lastPag9
AND (lastAetion # WriteD
OR bytes = lastBytes) THEN RETURN:
firstNewPage ~ firstPage+1:
END:
IF firstNewPage (= lastPage THEN
BEGIN aop.da ~ da:
aop.firstPage ~ firstNewPage:
aop. lastPage ~ lastPage:
AssignPages[@aop]:
END:
[page,bytes] ~ RewritePages[@loeal]:
RETURN
END: END:
-- Note that only da, firstPage, and lastPage are valid on entry.
AssignPages: PROCEDURE [arg:POINTER TO update DiskRequest] =
BEGIN OPEN SegmentDefs. arg: i: PageNumber:
DAs: DAvee = DESCRIPTOR[da.lastPage+2]:
sink: DataSegmentHandle = NewDataSegment[DefaultBase,l]:
arg t ~ DiskRequest [
DataSegmentAddress[sink]. ",NIl,TRUE,ReadlO.
ReadlD.FAlSE.update[CheekFreePage]]:
UNTIL firstPage > lastPage DO
ENABLE UNWIND =) DeleteDataSegment[sink]:
FOR i IN [firstPage .. lastPage] DO
DAs[i] ~ DiskKDDefs.AssignDiskPage[DAs[i-l]]:
ENDlOOP:
i ~ firstPage:
[] ~ ActOnPages[arg I UnreeoverableDiskError--[cb]-- =)
BEGIN -- skip bad spots and press on
firstPage ~ eb.page:
DAs[firstPage] ~ fillinDA:
firstPage ~ firstPage+l:
RETRY
END] ;
firstPage ~ i;
FOR i IN [fi rstPage .. I astPage] DO
IF (DAs[firstPage] ~ DAs[i]) # fillinDA
THEN firstPage ~ firstPage+l:
ENDLOOP;
ENDlOOP;
DeleteDataSegment[sink]:
RETURN
END;
FreePageFID: FID = FID[-1.SN[1.1.1.17777B.-l]];
CheckFreePage: PROCEDURE[eb:CBptr] =
BEGIN
DAs: POINTrR TO ARRAY [0 .. 1) Of vDA = cb.zone.info;
If cb.labelAddress.fileID # FreePageFIO
THfN DAst[cb.page] ... fillinDA;
RETURN
END;
bfs .mesa 24-0CT-77 21:15:31 Page 3
-- Note that action and lastAction are not used (WriteLD is assumed).
RewritePages: PUBLIC PROCEDURE (arg:POINTER TO extend DiskRequest]
RETURNS [PageNumber. CARDINAL] =
BEGIN OPEN arg: i: PageNumber;
cbzone: ARRAY [o .. lCBZ) OF UNSPECIFIED;
zone: CBZptr = @ebzone[o]; eb: CBptr;
CAs: CAvee = DESCRIPTOR[ea.lastPage+1];
DAs: DAvee = DESCRIPTOR(da.lastPage+2];
ddc: DOC ~ DDC[.ea