Google
 

Trailing-Edge - PDP-10 Archives - dec-10-omona-u-mc9 - tmpuuo.mac
There are 6 other files named tmpuuo.mac in the archive. Click here to see a list.
TITLE	TMPUUO -- TEMPORARY FILE STORAGE UUO - V014
SUBTTL	TONY LAUCK  24 AUG 76
	SEARCH	F,S
	$RELOC
	$HIGH
;***COPYRIGHT 1973,1974,1975,1976,1977 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.***
XP VTMPUU,014		;PUT VERSION NUMBER IN GLOB AND MAP

REPEAT 0,<

		TEMPORARY FILE STORAGE FOR JOB UUO.

	THE	"TMPCOR" UUO IS USED TO ENABLE A JOB TO LEAVE SEVERAL SHORT
FILES IN CORE FROM THE RUNNING OF ONE USER PROGRAM OR CUSP TO THE
NEXT. THESE FILES MAY BE REFERRED TO BY A THREE CHARACTER FILE NAME,
AND ARE UNIQUE TO EACH JOB, I.E. A JOB CAN ONLY REFERENCE ITS OWN
FILES. ALL FILES ARE ALWAYS DELETED WHEN A JOB IS KILLED.

	EACH	FILE APPEARS TO THE USER AS ONE DUMP MODE BUFFER. THE ACTUAL SIZE OF A
TEMPORARY FILE, THE NUMBER OF TEMPORARY FILES A USER CAN HAVE,
AND THE TOTAL CORE SPACE A USER CAN TIE UP ARE PARAMETERS DETER-
MINED AT MONGEN TIME. ALL TEMPARARY FILES RESIDE IN A FIXED AREA
IN THE MONITOR, BUT THE SPACE IS DYNAMICALLY ALLOCATED AMOUNG
DIFFERENT JOBS AND THE SEVERAL DIFFERENT FILES OF ANY GIVEN JOB.

	THE	PRIMARY PURPOSE OF THE TEMPORARY STORAGE SYSTEM IS FOR SHORT
CONTROL FILES, E.G. CCL FILES, TO LIVE IN CORE, THEREBY SPEEDING
UP RESPONSE TIMES AND REDUCING DISK OPERATIONS. ACCORDINGLY, 
SHOULD A PROGRAM ATTEMPT TO WRITE A FILE WHEN THERE IS 
INSUFFICIENT SPACE, EITHER IN THE ENTIRE BUFFER AREA OR BECAUSE
THE USER HAS EXCEEDED HIS QUOTA, THE UUO GIVES AN ERROR RETURN.
THE CUSP CAN THEN WRITE THE DATA AS A SHORT DISK FILE.
SIMILARLY, SHOULD A PROGRAM FAIL TO FIND A FILE UPON READING IT,
IT WILL GET AN ERROR RETURN AND CAN THEN LOOKUP A SHORT DISK FILE.


	IT	IS VERY IMPORTANT TO REALIZE THE TEMPORARY NATURE OF THESE
FILES. FOR EXAMPLE, UPON WRITING, THE OLD FILE IS DELETED BEFORE
CHECKING FOR SPACE FOR A NEW VERSION. THE OLD FILE COULD BE LOST WITHOUT
A NEW ONE REPLACING IT. ALSO, THERE CAN BE NO GUARANTEE THAT FILES
WILL FIT IN CORE.


	THE	TMPCOR UUO IS NOT INTENDED TO REPLACE A FUTURE, MORE
GENERAL, DEVICE INDEPENDENT SERVICE ROUTINE FOR "CORE". HOWEVER,
THE SPACE TAKEN UP BY DEVICE DATA BLOCKS, ETC., IN THAT MORE
GENERAL ROUTINE WOULD REPRESENT UNNECESSARY OVERHEAD FOR EXTREMELY
SHORT DATA, SUCH AS CCL COMMAND FILES.
>
	REPEAT	0,<
	FORMAT	OF TEMPORARY FILE STORAGE UUO.

	CALL	AC, [SIXBIT /TMPCOR/]	;CALLI INDEX=44
	;ERROR RETURN
	;NORMAL RETURN

	C(AC) MUST ALWAYS BE SET UP BY THE USER PROGRAM PRIOR TO EXECUTING
THE UUO. IT IS CHANGED BY THE UUO AND RETURNS A VALUE THAT DEPENDS
ON THE PARTICULAR FUNCTION PERFORMED.

	C(AC) = XWD CODE,BLOCK

BLOCK:	XWD	NAME,0		;NAME IS FILE NAME
	IOWD	BUFLEN,BUFFER	;USER BUFFER AREA (ZERO  FOR NO BUFFER)
>
	REPEAT	0,<
		CODE-0	--  GET FREE SPACE

	THE	IS THE ONLY FORM OF THE TEMP UUO THAT DOES NOT USE A TWO
WORD PARAMETER BLOCK. C(AC) WOULD ORDINARLY BE SET TO ZERO FOR THE
GET FREE SPACE UUO. THE USER PROGRAM ALWAYS GETS A NORMAL RETURN
(UNLESS THE SYSTEM DOES NOT HAVE THE TEMP UUO). C(AC) IS SET TO
THE NUMBER OF WORDS OF FREE SPACE AVAILABLE TO THE USER.


		CODE=1	--  READ FILE

	IF	THE SPECIFIED FILE NAME IS NOT FOUND, C(AC) IS SET TO THE
NUMBER OF FREE WORDS OF SPACE AVIALABLE FOR TEMP FILES, AND THE
ERROR RETURN IS TAKEN.

	IF	THE FILE IS FOUND, C(AC) IS SET TO THE LENGTH OF THE
FILE IN WORDS, AND AS MUCH OF THE FILE AS WILL FIT IS COPIED INTO
THE USERS BUFFER. THE USER CAN CHECK FOR TRUNCATION BY COMPARING
C(AC) WITH BUFLEN UPON SUCCESSFUL RETURN FROM THE TEMP UUO.


		CODE=2	--  READ AND DELETE FILE

	THIS	IS THE SAME AS CODE=1, EXCEPT THAT IF A FILE WAS FOUND
IT IS ALSO DELETED AND ITS SPACE RECLAIMED.
>
	REPEAT	0,<
		CODE=3	--  WRITE FILE

	IF	THERE IS ALREADY A FILE OF THE SPECIFIED NAME, IT IS
DELETED AND ITS SPACE IS RECLAIMED.

	THE	REQUESTED SIZE OF THE FILE IS SPECIFIED BY BUFLEN. 
IF THERE IS NOT ENOUGH SPACE TO WRITE THE ENTIRE FILE, NOTHING
IS WRITTEN, C(AC) IS SET TO THE NUMBER OF FREE WORDS OF SPACE 
AVAILABLE TO THE USER, AND THE ERROR RETURN IS TAKEN.

	IF	THERE IS ENOUGH SPACE, THE FILE IS WRITTEN. C(AC) IS SET TO
THE AMOUNT OF SPACE LEFT AFTER THE FILE HAS BEEN WRITTEN AND THE
NORMAL RETURN IS TAKEN. FILES ARE ALWAYS FILLED UP WITH ZEROS TO THE
NEXT EVEN MULTIPLE OF THE BLOCK LENGTH (TMPBL).
	THIS	EVEN LENGTH IS READ BACK IN.


		CODE=4	--  READ DIRECTORY

	THE	ERROR RETURN IS NEVER TAKEN.

	C(AC) IS SET TO THE NUMBER OF DIFFERENT FILES IN THE JOB'S
TEMPORARY FILE AREA. IN ADDITION, AN ENTRY IS MADE FOR EACH FILE
IN THE USER BUFFER AREA UNTIL THERE IS NO MORE SPACE OR ALL FILES HAVE
BEEN LISTED. THE USER PROGRAM CAN CHECK FOR TRUNCATION BY COMPARING
C(AC) UPON RETURN WITH BUFLEN.

	DIRECTORY ENTRY FORMAT
	XWD  NAME,SIZE	;NAME=FILE NAME, SIZE =FILE LENGTH IN WORDS.


		CODE=5	--  READ AND CLEAR DIRECTORY

	THIS	IS THE SAME AS CODE=4 EXCEPT THAT ANY FILES IN THE JOB'S
TEMPORARY STORAGE AREA ARE ALSO DELETED AND THEIR SPACE RECLAIMED.

	THIS	UUO IS EXECUTED BY THE LOGOUT CUSP.
>
	REPEAT	0,<
		IMPLEMENTATION

	MASTER	DIRECTORY

	THIS	IS A TABLE JOBN+1 ENTRIES LONG.

JBTTMP:	XWD	FREE,IDLE
JBTTM1:	XWD	SPACE,LINK
	   .
	   .
	   .

MREE = NO. OF FREE BLOCKS IN MONITOR BUFFER AREA
IDLE  =  LINK TO FIRST FREE BLOCK OR 0 IF NO FREE BLOCKS
SPACE  =  NO OF FREE BLOCKS REMAINING IN JOBS QUOTA
LINK  =  LINK TO FIRST BLOCK OF FIRST FILE OF JOB, 0 IF NONE.


	IDLE	BLOCK FORMAT

	XWD	0,LINK
	REPEAT	TMPBL, <0
			>

	LINK  = LINK TO NEXT BLOCK ON IDLE CHAIN, 0 IF NO MORE.

	USER	BLOCK FORMAT

	XWD	NAME,LINK
	BLOCK	TMPBL		;USER DATA OR ZERO FILL.

	NAME	= USER FILE NAME.
	LINK	= LINK TO NEXT BLOCK IN THIS FILE OR NEXT FILE OF THIS USER

	IF	A FILE IS SEVERAL BLOCKS LONG, EACH BLOCK HAS THE FILE NAME.
	A	LINK OF 0 INDICATES NO MORE DATA IN THE FILE, AND NO MORE FILES
FOR THIS USER.

	THEREFORE, A FILE ENDS WHEN ITS LAST BLOCK HAS A ZERO LINK, OR 
WHEN IT LINKS TO A FILE OF DIFFERENT NAME.



	MONITOR	BUFFER AND PARAMETERS

TMPBUF:	BLOCK	TMPBKS*<TMPBL+1>	;BUFFER AREA FOR ALL FILES.

	TMPBKS	IS THE NUMBER OF BLOCKS THE STORAGE AREA IS COMPUTED.
	IT	IS COMPUTED BY MACRO DURING THE ASSEMBLY OF COMMON.
	TMPBL	IS A PARAMETER IN S.MAC.
>
	REPEAT	0,<
	FACTORS	AFFECTING SYSTEM

	1. MONITOR MUST INITALIZE THE TEMP FILES ON RESTART.
	A) CLEAR ENTIRE BUFFER AREA
	B) SET FREE COUNT TO TOTAL NUMBER OF 5 WORD BLOCKS
	C) LINK ALL BLOCKS ON IDLE CHAIN
	D) SET ALL USERS SPACE TO THEIR QUOTA AND LINKS TO 0


	2.  LOGOUT MUST DO A CLEAR OF USERS DIRECTORY

	3. PIP SHOULD CLEAR USERS DIRECTORY ON A DEL *.TMP COMMAND

	4.  PIP SHOULD READ AND WRITE TEMP FILES. DEVICE TMP:?

	5.  ALL CCL CUSPS MUST BE CHANGED TO DO TEMP UUO.
>
	ENTRY	TMPUUO
	INTERN	TMPUUO,TMPTAB
	EXTERN	CPOPJ,CPOPJ1,STOTAC,GETWDU,UUOERR,JBTTMP,GETWD1,PUTWD1

TMPTAB:	0			;FREE DATA SPACE,ADDRESS OF TABLE
	0			;USER QUOTA,NUMBER OF BLOCKS
TMPUUO:	PUSHJ	P,SAVE4##	;SAVE P1-P4
	AOS	(P)		;SET FOR GOOD RETURN
	MOVE	P4,T1		;GET USERS AC
	TLNN	P4,-1		;IS CODE = 0?
	JRST	TMPSP		;YES, SO JUST RETURN SPACE LEFT
	HRR	M,P4		;SETUP M TO GET FIRST WORD OF BLOCK
	PUSHJ	P,GETWDU	;GET FIRST WORD
	HLLZ	S,T1		;SAVE FILE NAME
	PUSHJ	P,GETWD1	;GET SECOND WORD
	HLRE	U,T1		;GET USER'S BUFFER LENGTH
	MOVNS	U
	HRR	M,T1		;USER'S BUFFER ADDRESS
IFN FTVM,<
	HRRZS	T2,T1		;START OF USER'S BUFFER -1
	ADDI	T1,1		;START OF BUFFER
	ADDI	T2,(U)		;END OF BUFFER
	PUSHJ	P,TRNGE##	;MAKE SURE THAT THE ENTIRE BUFFER IS IN CORE
>
	HLRZS	P4		;GET CODE
	CAILE	P4,TMPDL		;CHECK IF IT IS LEGAL
	JRST	UUOERR		;NO
	JRST	@TMPDIS-1(P4)	;DISPATCH TO APPROPRIATE ROUTINE

TMPDIS:	JRST	TMPREA
	JRST	TMPREA
	JRST	TMPWR
	JRST	TMPDIR
	JRST	TMPDIR

	TMPDL= .-TMPDIS
	;ROUTINE TO READ, OR READ AND DELETE A TEMPORARY FILE

TMPREA:	PUSHJ	P,TMPSRC	;FIND FILE
	JRST	TMPSPB		;NONE, SO RETURN SPACE
	SETZ	T3,		;ZERO USER COUNT
TMPRE1:	HRLI	P1,-TMPBL	;SET COUNT TO NO WORDS IN BLOCK
TMPRE2:	SOJL	U,TMPR2A	;COUNT DOWN USER BUFFER SPACE
	MOVE	T1,1(P1)
	PUSHJ	P,PUTWD1	;IF SPACE, COPY 1 WORD
TMPR2A:	ADDI	T3,1		;ADD TO USER COUNT
	AOBJN	P1,TMPRE2	;GO ON WITH BUFFER IF MORE WORDS
	SUBI	P1,TMPBL	;GET BACK TO START OF BLOCK
	TRNN	P4,1		;SHOULD WE DELETE?
	PUSHJ	P,TMPDEL	;DELETE THIS BLOCK
	PUSHJ	P,TMPCHA	;CHAIN TO NEXT BLOCK IN FILE
	JRST	TMPRE1		;FOUND, GO HANDLE IT
TMPRE3:	SETZ	T1,
TMPFLL:	SOJL	U,STOT3		;FILL REST OF USERS BUFFER
	PUSHJ	P,PUTWD1	;WITH ZEROS, THEN GIVE HIM COUNT
	AOJA	T4,TMPFLL


	;ROUTINE TO CHAIN TO NEXT BLOCK OF A FILE

TMPCHA:	HRRZ	P1,(P1)		;CHAIN TO NEXT BLOCK
	HLLZ	P3,(P1)		;GET FILE NAME
	CAMN	P3,S		;MATCH?
	JUMPN	P1,CPOPJ	;YES, IS THERE A BLOCK?
	JRST	CPOPJ1		;NO, SKIP RETURN


	;ROUTINE TO FIND A FILE

TMPSRC:	MOVEI	P2,JBTTMP(J)	;GET ADDRESS OF FIRST LINK
TMPSR1:	HRRZ	P1,(P2)		;CHAIN FORWARD
	JUMPE	P1,CPOPJ	;NONE, FILE NOT FOUND
	HLLZ	T2,(P1)		;GET FILE NAME
	CAMN	T2,S		;MATCH?
	JRST	CPOPJ1		;YES, SKIP RETURN
	HRRZ	P2,P1		;SAVE OLD POINTER
	JRST	TMPSR1		;AND KEEP ON LOOKING




	;ROUTINE TO DELETE A BLOCK

TMPDEL:	HRRZ	P3,(P1)		;LINK AROUND BLOCK
	HRRM	P3,(P2)
	HRRZ	P3,JBTTMP	;LINK OLD BLOCK TO IDLE
	MOVEM	P3,(P1)
	HRRM	P1,JBTTMP	;LINK START OF IDLE CHAIN TO BLOCK
	HRRZ	P1,P2		;RESTORE P1 FOR TMPCHA
	MOVSI	P3,TMPBL	;UPDATE FREE COUNTERS
	ADDM	P3,JBTTMP
	ADDM	P3,JBTTMP(J)
	POPJ	P,
	;ROUTINE TO WRITE A FILE FOR USER

TMPWR:	JUMPE	S,TMPSPB	;DISALLOW NULL NAME
	PUSHJ	P,TMPSRC	;SEE IF THERE WAS AN OLD FILE
	JRST	TMPWR2		;NO
TMPWR1:	PUSHJ	P,TMPDEL	;DELETE A BLOCK
	PUSHJ	P,TMPCHA	;CHAIN TO NEXT BLOCK
	JRST	TMPWR1		;THERE WAS ONE, GO ON

TMPWR2:	PUSHJ	P,TMPSPC	;GET SPACE FOR USER
	SKIPE	T3
	CAMLE	U,T3		;DOES HE WANT MORE?
	JRST	TMPSPB		;YES, SO TELL HIM HE LOST

	HRRZ	P3,JBTTMP(J)	;SAVE LINK TO FIRST FILE
	MOVEI	P2,JBTTMP(J)	;SET OLD BLOCK ADDRESS

TMPWR3:	HRRZ	P1,JBTTMP	;GET ADDRESS OF FIRST IDLE BLOCK
	HRRZ	T2,(P1)		;GET ITS SUCCESSOR
	HRRM	T2,JBTTMP	;LINK THAT BLOCK TO IDLE CHAIN
	HRRM	P1,(P2)		;LINK LAST BLOCK OF USER TO NEW BLOCK
	HRRZ	P2,P1		;SAVE OLD BLOCK ADDRESS
	MOVSI	T2,-TMPBL	;DECREASE JOB AND TOTAL SPACE
	ADDM	T2,JBTTMP
	ADDM	T2,JBTTMP(J)

	HRRZM	P3,(P1)		;LINK UP BLOCK
	HLLM	S,(P1)		;INSERT FILE NAME
	HRLI	T4,-TMPBL	;SET FOR NO WORDS/BLOCK
TMPWR4:	SOJL	U,TMPWR6	;DOES HE WANT TO WRITE MORE?
	PUSHJ	P,GETWD1	;GET A WORD
	PUSH	P1,T1		;YES, SO STICK IN HIS WORD
TMPWR5:	AOBJN	T4,TMPWR4	;UPDATE USER ADDR, IS BLOCK DONE?
	JUMPG	U,TMPWR3	;YES, DOES HE HAVE MORE?

	JRST	TMPSP		;GET SPACE AND RETURN

TMPWR6:	SETZM	1(P1)		;FILL FINAL BLOCK WITH ZERO
	AOJA	P1,TMPWR5	;AND GO ON UNTIL BLOCK DONE


	;ROUTINE TO COMPUTE SPACE FOR USERS TMP FILES

TMPSPC:	HLRZ	T3,JBTTMP	;TOTAL FREE SPACE
	HLRZ	T2,JBTTMP(J)	;USER LIMIT
	CAMLE	T3,T2		;SPACE IS MINIMUM OF THE TWO
	MOVE	T3,T2
	POPJ	P,


	;ROUTINE TO GET SPACE AND RETURN TO USER (SKIP AND NO SKIP)

TMPSPB:	SOS	(P)		;NO SKIP RETURN
TMPSP:	PUSHJ	P,TMPSPC	;GET SPACE
STOT3:	MOVE	T1,T3		;SET TO STORE T3
	JRST	STOTAC		;RETURN IT
	;READ DIRECTORY, READ AND CLEAR DIRECTORY

TMPDIR:	SETZ	T3,		;ZERO COUNT OF FILES
	MOVEI	P2,JBTTMP(J)	;SET LINK TO DELETE
	HRRZ	P1,(P2)		;LINK TO FIRST BLOCK
TMPDI1:	JUMPE	P1,TMPRE3	;IF NONE, ZERO REST OF USERS BUFFER
	HLLZ	S,(P1)		;GET FILE NAME
	MOVEI	T1,1		;SET LENGTH TO 1
TMPDI2:	TRNE	P4,1		;DELETE?
	PUSHJ	P,TMPDEL	;YES, DELETE BLOCK
	PUSHJ	P,TMPCHA	;GET NEXT BLOCK OF FILE
	AOJA	T1,TMPDI2	;THERE IS ONE, SO COUNT BLOCKS
	IMULI	T1,TMPBL	;GET LENGTH IN WORDS
	HLL	T1,S		;DONE, GET LENGTH, NAME OF OLD ONE
	SOSL	U		;IS THERE SPACE LEFT IN USER AREA?
	PUSHJ	P,PUTWD1	;YES, STOW ENTRY
	AOJA	T3,TMPDI1	;COUNT FILES, GO ON FOR NEXT ONE

	END