Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50232/cobslp.mac
There are no other files named cobslp.mac in the archive.
TITLE	********** ROUTINE TO ALLOW COBOL TO SLEEP **********
SUBTTL			*** WORDS OF WISDOM ***


















;*******************************************************************
;*                                                                 *
;*	BETTER IS THE POOR THAT WALKETH IN HIS INTEGRITY,          *
;*	THAN HE THAT IS PERVERSE IN HIS LIPS, AND IS A             *
;*	FOOL. A FALSE WITNESS SHALL NOT BE UNPUNISHED, AND         *
;*	HE THAT SPEAKETH LIES SHALL NOT ESCAPE.                    *
;*                                                                 *
;*******************************************************************















SUBTTL			*** INSTRUCTIONS ***

COMMENT @	"COBSLP" -- SLEEP SUBROUTINE FOR COBOL
		--------------------------------------

	THIS SUBROUTINE IS ENTERED FROM COBOL WITH A PARAMETER AREA
SET UP INDICATING THE SLEEP TIME AND THE ENABLE BITS TO BE USED WHEN
THIS JOB GOES TO SLEEP. COBSLP WILL THEN SET THE ENABLE BITS AND SLEEP
FOR THE SPECIFIED TIME INTERVAL. NOTE IF A ZERO TIME INTERVAL IS
SPECIFIED THE SLEEP WILL BE ETERNAL OR UNTIL THE JOB IS AWAKENED
BY SOME EXTERNAL EVENT.

	COBSLP EXPECTS THE FOLLOWING TYPE OF PARAMETER AREA TO BE SET
UP BEFORE ENTRY INTO THE SUBROUTINE:

	01	WAIT-ARGUMENTS.
		02	WAIT-BITS	PIC X(6).
		02	WAIT-TIME	PIC S9(4)	COMP.

	COBSLP IS THEN ENTERED FROM COBOL WITH THE FOLLOWING COBOL
STATEMENT:

	ENTER MACRO COBSLP USING WAIT-ARGUMENTS.

	ON RETURN WAIT-BITS SHOULD BE EXAMINED. IT WILL HOLD ONE
OF FOUR POSIBLE VALUES. THESE VALUES AND THEIR MEANINGS ARE
LISTED BELOW:

	ERROR		THE HIBERNATE UUO FAILED.

	"JOBNUMBER"	RETURNED ONLY WHEN COBSLP IS CALLED FOR
			THE FIRST TIME. THIS APPEARS IN SIXBIT
			LEFT JUSTIFIED IN WAIT-BITS.

	TTY		IF THE JOB WAS AWAKENED BECAUSE OF PENDING
			TELETYPE INPUT.

	"NULL"		IF THE JOB WAS AWAKENED FOR ANY REASON
			OTHER THEN PENDING TELETYPE INPUT.
	COBSLP REQUIRES A DUMMY FIRST TIME CALL TO SET THE INITIAL
WAIT-BITS. THIS SHOULD BE DONE IN THE VERY BEGINNING OF THE
COBOL PROGRAM THAT IS TO USE COBSLP. THIS DUMMY CALL WILL THEN RETURN
THE JOB'S JOB NUMBER IN WAIT-BITS. NOTE THAT EACH TIME COBSLP
IS CALLED WAIT-BITS MUST BE SET, FOR IT IS REPLACED WITH A NEW VALUE
EACH TIME CONTROL RETURNS TO THE COBOL PROGRAM.

	THE FOLLOWING IS AN EXPLAINATION OF THE PARAMETER AREA THAT
COBSLP MUST BE CALLED WITH:

	WAIT-BITS		ENABLE BITS FOR THE OPERATION.
				THE FOLLOWING IS A LIST OF LEGAL
				BITS AND THE SYMBOLS THAT THEY
				REPRESENT. THE SYMBOLS SHOULD APPEAR
				IN WAIT-BITS BEFORE A CALL IS MADE TO
				COBSLP.

				U	SAME PROJECT NUMBER REQUIRED TO
					WAIT THIS JOB.
				N	SAME PROGRAM NUMBER REQUIRED TO
					WAKE THIS JOB.
				O	ONLY THIS JOB CAN WAKE ITSELF.
				C	WAKE ON CHARACTER READY (INPUT).
				L	WAKE ON LINE READY (INPUT).
				P	WAKE ON PTY ACTIVITY.

	WAIT-TIME		TIME IN SECONDS TO SLEEP. IF ZERO SLEEP
				WILL BE ETERNAL OR UNTIL ONE OF THE
				ABOVE CONDITIONS IS SATISFIED.

	COBSLP IS LOADED ALONG WITH THE COBOL PROGRAM THAT IS TO
EXECUTE IT. THE FOLLOWING "CCL" COMMAND CAN BE USED TO LOAD COBSLP
PROVIDED COBSLP.REL IS IN THE SYSTEM LIBRARY [1,4].

	LOAD "COBOL PROGRAM NAME",SYS:COBSLP

	THE JOB CAN THEN BE SAVED WITH THE MONITOR COMMAND "SSAVE JOBNAME"
OR "SAVE JOBNAME".
@
SUBTTL			*** DEFINITIONS ***

;	ACCUMULATOR DEFINITIONS.

S=0					;USED TO HOLD BITS FOR HIBERNATE.
T1=1					;TEMPORARY AC'S.
T2=2
T3=3
HP=16					;HOLDS POINTER TO COBOL ARGUMENTS.
PDP=17					;PUSH-DOWN POINTER.

;	OPCODE DEFINITIONS.

OPDEF	MME	[XWD 047000,000000]	;MASTER MODE ENTRY.
OPDEF	NOP	[JFCL]			;NO OPERATION.

;	MASTER MODE ENTRY SYMBOLS.

.JOB==30				;RETURN JOB NUMBER.
.HIBER==72				;PUT ME TO SLEEP.
.WAKE==73				;WAKE ME UP.

;	CONSTANTS.

ZERO==0					;USED IN INDEXING.
ONE==1					;DITTO.

;	THINGS WHICH HAVE NO OTHER PLACE TO LIVE.

ENTRY	COBSLP				;PROGRAM ENTRY POINT.
SUBTTL			*** SLEEP CONTROL ***

;HERE TO PUT THIS JOB INTO A SLEEP STATE.
;COBSLP ASSUMES THAT IT IS CALLED FROM COBOL
;WITH THE FOLLOWING PARAMETER AREA SET UP:
;
;	01  WAIT-ARGUMENTS.
;	   02  WAIT-BITS	PIC X(6).
;	   02  WAIT-TIME	PIC S9(4)  COMP.
;
;COBSLP IS THEN ENTERED WITH THE FOLLOWING COBOL
;STATEMENT:
;
;ENTER MACRO COBSLP USING WAIT-ARGUMENTS.

COBSLP:	MOVE	HP,ZERO(PDP)		;PICK UP POINTER TO POINTER.
	MOVE	HP,@ZERO(HP)		;GET ACTUAL BYTE POINTER TO ARGUMENTS.
	SKIPE	FSTFLG			;SKIP IT THIS IS FIRST TIME HERE.
	JRST	BYEBYE			;NO NEED TO WAKE IF NOT.
	MME	T1,.JOB			;GET JOB NUMBER.
	MME	T1,.WAKE		;WAKE ME UP...
	NOP				;NICE TRY IF FAIL...
BYEBYE:	SETZM	S			;CLEAR STATUS REGISTER.
	MOVNI	T1,6			;COUNT OF MAX NUMBER OF BITS TO SET.
H.NXT:	ILDB	T2,HP			;PICK UP A BIT NAME.
	HRLZI	T3,-H.CNT		;COUNT OF LEGAL BITS.
H.SET:	CAME	T2,H.TAB(T3)		;TEST FOR A MATCH.
	AOBJN	T3,H.SET		;TEST THE WHOLE LIST.
	IOR	S,H.BIT(T3)		;SET THE BIT.
	AOJN	T1,H.NXT		;DO ALL THE BITS.
	HRR	T1,ONE(HP)		;GET THE SLEEP TIME.
	IMULI	T1,^D1000		;CONVERT TO MILISECONDS.
	HRR	S,T1			;PLACE IN THE RIGHT PLACE.
	MME	S,.HIBER		;PUT ME AWAY.
	JRST	NOHIB			;FAILURE...
	SKIPN	FSTFLG			;FIRST TIME FLAG  SET.
	JRST	FSTTIM			;YES RETURN JOB NUMBER.
	MOVEI	S,1			;CLEAR THIS AND GO TO SLEEP AGAIN.
	MME	S,.HIBER		;THIS IS TO CLEAR THE WAKE BIT.
	NOP				;IGNORE BAD RETURNS.
	MOVSI	T1,'TTY'		;TEST HERE TO SEE IF LIFE CAME FROM TTY.
	SKPINC				;MAKE THE CHECK.
	SETZM	T1			;SOME OTHER REASON.

RET:	MOVEM	T1,ZERO(HP)		;SAVE REASON OR JOB NUMBER.
	SETOM	FSTFLG			;SET FLAG TO SAY WE'VE BEEN HERE.
	AOS	(PDP)			;BUMP POINTER.
	POPJ	PDP,COBSLP		;BACK TO COBOL.
;HERE WHEN THE HIBERNATE MME FAILS.

NOHIB:	MOVE	T1,[SIXBIT "ERROR"]	;SAY IT IS AN ERROR.
	JRST	RET			;AND RETURN.

;HERE TO RETURN THE JOB NUMBER.

FSTTIM:	SETZM	T3			;CLEAR REGISTER TO GET RESULT.
	MME	T1,.JOB			;PICK UP JOB NUMBER.

OCTDEC:	IDIVI	T1,^D10			;GET A DIGIT.
	ADDI	T2,20			;CONVERT TO SIXBIT.
	LSHC	T2,-6			;SHIFT IN NEW DIGIT.
	SKIPE	T1			;SKIP IF LAST DIGIT.
	JRST	OCTDEC			;GET THE NEXT.
DECDON:	MOVE	T1,T3			;PUT IT IN THE RIGHT PLACE.
	JRST	RET			;VANISH...

H.TAB:	SIXBIT	"     U"		;SAME PROJECT REQUIRED TO WAKE ME.
	SIXBIT	"     N"		;SAME PROGRAMER REQUIRED TO WAKE ME.
	SIXBIT	"     O"		;ONLY I CAN WAKE ME.
	SIXBIT	"     C"		;WAKE ME ON CHARACTER READY.
	SIXBIT	"     L"		;WAKE ME ON LINE READY.
	SIXBIT	"     P"		;WAKE ME ON PTY READY.
H.CNT=.-H.TAB				;COUNT OF BITS.

H.BIT:	000001000000			;BITS TO SET.
	000002000000
	000004000000
	000010000000
	000020000000
	000040000000
	000000000000			;ERROR BITS TO SET [I.E. -- NONE].

FSTFLG:	000000000000			;FIRST TIME FLAG.

PRGLEN==.-COBSLP				;PROGRAM LENGTH IN OCTAL.

	END				;TERMINUS.....