MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (1)    3800  HISTORY			; DETAILED

   (1)    4700  DECLARATIONS

   (1)    6400  SCH$RWAIT - RESOURCE WAIT

   (1)   10200  SCH$LOCKWNOWAIT - LOCK MUTEX FOR WRITE WITHOUT 

   (1)   15000  SCH$IOLOCKW - LOCK I/O DATA BASE MUTEX FOR WRIT

   (1)   18600  SCH$LOCKW - LOCK MUTEX FOR WRITE

   (1)   23300  SCH$IOLOCKR - LOCK I/O DATABASE MUTEX FOR READ

   (1)   26900  SCH$LOCKR - LOCK MUTEX FOR READ

   (1)   32900  SCH$RAVAIL - DECLARE RESOURCE AVAILABILITY

   (1)   35500  SCH$IOUNLOCK - UNLOCK I/O DATABASE MUTEX

   (1)   38400  SCH$UNLOCK - UNLOCK MUTEX

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   1

X01                                                                                                                              (1)



                                     0000   100 

                                     0000   200 	.TITLE	MUTEX - MUTEX WAIT ROUTINES

                                     0000   300 	.IDENT	/X01/		;

                                     0000   400 

                                     0000   500 ;

                                     0000   600 ; COPYRIGHT (C) 1977

                                     0000   700 ; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS 01754

                                     0000   800 ;

                                     0000   900 ; THIS SOFTWARE IS FURNISHED  UNDER A LICENSE FOR USE ONLY ON A SINGLE

                                     0000  1000 ; COMPUTER  SYSTEM AND  MAY BE  COPIED ONLY WITH  THE INCLUSION OF THE

                                     0000  1100 ; ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE, OR ANY OTHER COPIES THEREOF,

                                     0000  1200 ; MAY NOT BE PROVIDED OR  OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

                                     0000  1300 ; EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE

                                     0000  1400 ; TERMS.  TITLE TO AND  OWNERSHIP OF THE  SOFTWARE  SHALL AT ALL TIMES

                                     0000  1500 ; REMAIN IN DEC.

                                     0000  1600 ;

                                     0000  1700 ; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE

                                     0000  1800 ; AND SHOULD  NOT BE CONSTRUED  AS A COMMITMENT  BY DIGITAL  EQUIPMENT

                                     0000  1900 ; CORPORATION.

                                     0000  2000 ;

                                     0000  2100 ; DEC ASSUMES  NO  RESPONSIBILITY  FOR  THE USE OR  RELIABILITY OF ITS

                                     0000  2200 ; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

                                     0000  2300 

                                     0000  2400 ;++

                                     0000  2500 ; FACILITY: EXECUTIVE, SCHEDULER

                                     0000  2600 ;

                                     0000  2700 ; ABSTRACT:

                                     0000  2800 ;	THIS MODULE CONTAINS THE ROUTINES WHICH IMPLEMENT THE MUTEX

                                     0000  2900 ;	LOCK AND UNLOCK SERVICES FOR INTERNAL EXECUTIVE USE.

                                     0000  3000 ;

                                     0000  3100 ;

                                     0000  3200 ; ENVIRONMENT:

                                     0000  3300 ;	MODE = KERNEL

                                     0000  3400 ;

                                     0000  3500 ;--

                                     0000  3600 ;

                                     0000  3700 ;	.PAGE

                                     0000  3800 	.SBTTL	HISTORY			; DETAILED

                                     0000  3900 ;

                                     0000  4000 ; AUTHOR:	R. HUSTVEDT  CREATION DATE: 25-AUG-76

                                     0000  4100 ;

                                     0000  4200 ; MODIFIED BY:

                                     0000  4300 ;	, : VERSION

                                     0000  4400 ; 01	 -

                                     0000  4500 

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   2

X01             DECLARATIONS                                                                                                     (1)



                                     0000  4700 	.SBTTL	DECLARATIONS

                                     0000  4800 

                                     0000  4900 ;

                                     0000  5000 ; INCLUDE FILES:

                                     0000  5100 ;

                                     0000  5200 

                                     0000  5250 	$DYNDEF				; STRUCTURE TYPE DEFINITIONS

                                     0000  5300 	$IPLDEF				; IPL DEFINITIONS

                                     0000  5400 	$MTXDEF				; MUTEX DEFINITIONS

                                     0000  5500 	$PCBDEF				; PCB DEFINITIONS

                                     0000  5600 	$PRDEF				; PROCESSOR REGISTER DEFINITIONS

                                     0000  5700 	$PRIDEF				; PRIORITY INCR CLASS DEFS

                                     0000  5800 	$PSLDEF				; PSL DEFINITIONS

                                     0000  5900 	$STATEDEF			; SCHEDULER STATE DEFS

                                     0000  6000 	$WQHDEF				; WAIT QUEUE HEADER DEFS

                                     0000  6100 

                                 00000000  6200 	.PSECT	AEXENONPAGED,BYTE	; NONPAGED EXEC

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   3

X01             SCH$RWAIT - RESOURCE WAIT                                                                                        (1)



                                     0000  6400 	.SBTTL	SCH$RWAIT - RESOURCE WAIT

                                     0000  6500 

                                     0000  6600 ;++

                                     0000  6700 ; FUNCTIONAL DESCRIPTION:

                                     0000  6800 ;	SCH$RWAIT SUSPENDS THE EXECUTION OF A PROCESS UNTIL REQUIRED

                                     0000  6900 ;	RESOURCES ARE AVAILABLE.

                                     0000  7000 ;

                                     0000  7100 ; CALLING SEQUENCE:

                                     0000  7200 ;	SETIPL/DSBINT #IPL$_SYNCH

                                     0000  7300 ;	PUSHL	<PSL>

                                     0000  7400 ;	BSB/JSB	SCH$RWAIT

                                     0000  7500 ;

                                     0000  7600 ; INPUT PARAMETERS:

                                     0000  7700 ;	R0 - RESOURCE NUMBER FOR WHICH TO WAIT

                                     0000  7800 ;	R4 - PCB ADDRESS

                                     0000  7900 ;	00(SP) - PC AT WHICH TO RESUME

                                     0000  8000 ;	04(SP) - PSL WITH WHICH TO RESUME

                                     0000  8100 ;

                                     0000  8200 ; IMPLICIT INPUTS:

                                     0000  8300 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     0000  8400 ;	PCB OF CURRENT PROCESS

                                     0000  8500 ;

                                     0000  8600 ; OUTPUTS:

                                     0000  8700 ;	R0-R3 PRESERVED

                                     0000  8800 ;

                                     0000  8900 ; IMPLICIT OUTPUTS:

                                     0000  9000 ;	*** TBS ***

                                     0000  9100 ;

                                     0000  9200 ; SIDE EFFECTS:

                                     0000  9300 ;	*** TBS ***

                                     0000  9400 ;

                                     0000  9500 ;--

                                     0000  9600 

                                     0000  9700 SCH$RWAIT::				;;; RESOURCE WAIT ENTRY POINT

       0000'CF            50     E6  0000  9800 	BBSSI	R0,W^SCH$GL_RESMASK,WAITR	;;; SET WAITING FLAG

                          73         0005       

                          71     11  0006  9900 	BRB	WAITR			;;; AND ENTER WAIT STATE

                                     0008 10000 

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   4

X01             SCH$LOCKWNOWAIT - LOCK MUTEX FOR WRITE WITHOUT                                                                   (1)



                                     0008 10200 	.SBTTL	SCH$LOCKWNOWAIT - LOCK MUTEX FOR WRITE WITHOUT WAITING

                                     0008 10300 

                                     0008 10400 ;++

                                     0008 10500 ; FUNCTIONAL DESCRIPTION:

                                     0008 10600 ;	SCH$LOCKWNOWAIT LOCKS THE SPECIFIED MUTEX FOR EXCLUSIVE WRITE ACCESS

                                     0008 10700 ;	TO THE PROTECTED STRUCTURE.  IF ANOTHER PROCESS HAS ALREADY CLAIMED

                                     0008 10800 ;	THE MUTEX, THEN THIS ROUTINE RETURNS A FAILURE INDICATION.

                                     0008 10900 ;

                                     0008 11000 ;

                                     0008 11100 ;

                                     0008 11200 ; CALLING SEQUENCE:

                                     0008 11300 ;	BSB/JSB	SCH$LOCKWNOWAIT

                                     0008 11400 ;

                                     0008 11500 ;

                                     0008 11600 ; INPUT PARAMETERS:

                                     0008 11700 ;	R0 - ADDRESS OF MUTEX

                                     0008 11800 ;	R4 - PCB ADDRESS OF CURRENT PROCESS

                                     0008 11900 ;

                                     0008 12000 ; IMPLICIT INPUTS:

                                     0008 12100 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     0008 12200 ;	PCB OF CURRENT PROCESS

                                     0008 12300 ;	MUTEX LOCATED BY R0

                                     0008 12400 ;

                                     0008 12500 ; OUTPUTS:

                                     0008 12600 ;	R0 LOW BIT SET IF LOCKED SUCCESSFULLY

                                     0008 12700 ;	   LOW BIT CLEAR IF MUTEX IN USE

                                     0008 12800 ;	R1-R3 PRESERVED

                                     0008 12900 ;	IPL = ASTDEL

                                     0008 13000 ;

                                     0008 13100 ; IMPLICIT OUTPUTS:

                                     0008 13200 ;	*** TBS ***

                                     0008 13300 ;

                                     0008 13400 ; SIDE EFFECTS:

                                     0008 13500 ;	*** TBS ***

                                     0008 13600 ;

                                     0008 13700 ;--

                                     0008 13800 SCH$LOCKWNOWAIT::

                                     0008 13900 	SETIPL	#IPL$_SYNCH		;;; RAISE TO SYNCH IPL

            60            10     E6  000B 14000 	BBSSI	#MTX$V_WRT,(R0),20$	;;; SET WRITE PENDING

                          0D         000E       

                          60     B6  000F 14100 	INCW	MTX$W_OWNCNT(R0)	;;; RAISE OWNER COUNT

                          07     12  0011 14200 	BNEQ	10$			;;; RETURN FAILURE IF BUSY

            50       0000'8F     3C  0013 14300 	MOVZWL	#SS$_NORMAL,R0		;;; INDICATE SUCCESSFUL COMPLETION

                          32     11  0018 14400 	BRB	LKEX			;;; AND MERGE WITH COMMON EXIT CODE

                          60     B7  001A 14500 10$:	DECW	MTX$W_OWNCNT(R0)	;;; CORRECT COUNT

                          50     D4  001C 14600 20$:	CLRL	R0			;;; SET FAILURE RETURN INDICATION

                                     001E 14700 	SETIPL	#IPL$_ASTDEL		;;; LOWER TO ASTDEL

                                 05  0021 14800 	RSB				; AND RETURN

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   5

X01             SCH$IOLOCKW - LOCK I/O DATA BASE MUTEX FOR WRIT                                                                  (1)



                                     0022 15000 	.SBTTL	SCH$IOLOCKW - LOCK I/O DATA BASE MUTEX FOR WRITE

                                     0022 15100 ;++

                                     0022 15200 ; FUNCTIONAL DESCRIPTION:

                                     0022 15300 ;	SCH$IOLOCKW RETURNS TO THE CALLER WHEN THE I/O DATABASE MUTEX

                                     0022 15400 ;	HAS BEEN LOCKED FOR WRITE ASSURING EXCLUSIVE ACCESS.

                                     0022 15500 ;

                                     0022 15600 ;

                                     0022 15700 ;

                                     0022 15800 ; CALLING SEQUENCE:

                                     0022 15900 ;	BSB/JSB	SCH$IOLOCKW

                                     0022 16000 ;

                                     0022 16100 ;

                                     0022 16200 ; INPUT PARAMETERS:

                                     0022 16300 ;	R4 - PCB ADDRESS OF CURRENT PROCESS

                                     0022 16400 ;

                                     0022 16500 ; IMPLICIT INPUTS:

                                     0022 16600 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     0022 16700 ;	PCB OF CURRENT PROCESS

                                     0022 16800 ;	I/O DATABASE MUTEX

                                     0022 16900 ;

                                     0022 17000 ; OUTPUTS:

                                     0022 17100 ;	R0 = ADDRESS OF I/O DATABASE MUTEX

                                     0022 17200 ;	R1-R3 PRESERVED

                                     0022 17300 ;	IPL = ASTDEL

                                     0022 17400 ;

                                     0022 17500 ; IMPLICIT OUTPUTS:

                                     0022 17600 ;	*** TBS ***

                                     0022 17700 ;

                                     0022 17800 ; SIDE EFFECTS:

                                     0022 17900 ;	*** TBS ***

                                     0022 18000 ;

                                     0022 18100 ;--

                                     0022 18200  

                                     0022 18300 SCH$IOLOCKW::				; LOCK I/O DATA BASE FOR WRITE ACCESS

            50   00000000'EF     9E  0022 18400 	MOVAB	IOC$GL_MUTEX,R0		; GET ADDRESS OF I/O DATABASE MUTEX

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   6

X01             SCH$LOCKW - LOCK MUTEX FOR WRITE                                                                                 (1)



                                     0029 18600 	.SBTTL	SCH$LOCKW - LOCK MUTEX FOR WRITE

                                     0029 18700 ;++

                                     0029 18800 ; FUNCTIONAL DESCRIPTION:

                                     0029 18900 ;	SCH$LOCKW RETURNS TO THE CALLER WHEN THE SPECIFIED MUTEX

                                     0029 19000 ;	HAS BEEN LOCKED FOR WRITE ASSURING EXCLUSIVE ACCESS TO THE

                                     0029 19100 ;	PROTECTED STRUCTURE.

                                     0029 19200 ;

                                     0029 19300 ;

                                     0029 19400 ;

                                     0029 19500 ; CALLING SEQUENCE:

                                     0029 19600 ;	BSB/JSB	SCH$LOCKW

                                     0029 19700 ;

                                     0029 19800 ;

                                     0029 19900 ; INPUT PARAMETERS:

                                     0029 20000 ;	R0 - ADDRESS OF MUTEX

                                     0029 20100 ;	R4 - PCB ADDRESS OF CURRENT PROCESS

                                     0029 20200 ;

                                     0029 20300 ; IMPLICIT INPUTS:

                                     0029 20400 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     0029 20500 ;	PCB OF CURRENT PROCESS

                                     0029 20600 ;	MUTEX LOCATED BY R0

                                     0029 20700 ;

                                     0029 20800 ; OUTPUTS:

                                     0029 20900 ;	R0-R3 PRESERVED

                                     0029 21000 ;	IPL = ASTDEL

                                     0029 21100 ;

                                     0029 21200 ; IMPLICIT OUTPUTS:

                                     0029 21300 ;	*** TBS ***

                                     0029 21400 ;

                                     0029 21500 ; SIDE EFFECTS:

                                     0029 21600 ;	*** TBS ***

                                     0029 21700 ;

                                     0029 21800 ;--

                                     0029 21900 

                                     0029 22000 SCH$LOCKW::				; LOCK MUTEX FOR WRITE

                                     0029 22100 10$:	SETIPL	#IPL$_SYNCH		;;; RAISE TO SYNCH IPL

            60            10     E6  002C 22200 	BBSSI	#MTX$V_WRT,(R0),30$	;;; SET WRITE PENDING

                          08         002F       

                          60     B6  0030 22300 	INCW	MTX$W_OWNCNT(R0)	;;; RAISE OWNER COUNT

                          02     12  0032 22400 	BNEQ	20$			;;; WAIT IF BUSY

                          16     11  0034 22500 	BRB	LKEX			;;; MERGE WITH COMMON EXIT CODE

                                     0036 22600 

                                     0036 22700 20$:					;;; MUST WAIT FOR EXCLUSIVE USE

                          60     B7  0036 22800 	DECW	MTX$W_OWNCNT(R0)	;;; CORRECT COUNT

                          34     10  0038 22900 30$:	BSBB	WAITM			;;; AND WAIT FOR MUTEX

                          ED     11  003A 23000 	BRB	10$			; REPEAT LOCK ATTEMPT WHEN

                                     003C 23100 					; RESCHEDULED

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   7

X01             SCH$IOLOCKR - LOCK I/O DATABASE MUTEX FOR READ                                                                   (1)



                                     003C 23300 	.SBTTL	SCH$IOLOCKR - LOCK I/O DATABASE MUTEX FOR READ

                                     003C 23400 ;++

                                     003C 23500 ; FUNCTIONAL DESCRIPTION:

                                     003C 23600 ;	SCH$IOLOCKR RETURNS TO THE CALLER WHEN NO WRITERS OWN THE I/O

                                     003C 23700 ;	DATABASE MUTEX THUS ASSURING THE I/O DATABASE WILL REMAIN UN-

                                     003C 23800 ;	CHANGED UNTIL THE MUTEX IS RELEASED. IPL IS RAISED TO PREVENT

                                     003C 23900 ;	AST DELIVERY WHILE THE MUTEX IS OWNED AND THE PROCESS WILL NOT

                                     003C 24000 ;	BE OUTSWAPPED.

                                     003C 24100 ;

                                     003C 24200 ; CALLING SEQUENCE:

                                     003C 24300 ;	BSB/JSB	SCH$IOLOCKR

                                     003C 24400 ;

                                     003C 24500 ; INPUT PARAMETERS:

                                     003C 24600 ;	R4 - CURRENT PROCESS PCB ADDRESS

                                     003C 24700 ;

                                     003C 24800 ; IMPLICIT INPUTS:

                                     003C 24900 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     003C 25000 ;	PCB OF CURRENT PROCESS

                                     003C 25100 ;	I/O DATABASE MUTEX

                                     003C 25200 ;

                                     003C 25300 ; OUTPUTS:

                                     003C 25400 ;	R0 = ADDRESS OF I/O DATABASE MUTEX

                                     003C 25500 ;	R1-R3 PRESERVED

                                     003C 25600 ;	IPL = ASTDEL

                                     003C 25700 ;

                                     003C 25800 ; IMPLICIT OUTPUTS:

                                     003C 25900 ;	*** TBS ***

                                     003C 26000 ;

                                     003C 26100 ; SIDE EFFECTS:

                                     003C 26200 ;	*** TBS ***

                                     003C 26300 ;

                                     003C 26400 ;--

                                     003C 26500  

                                     003C 26600 SCH$IOLOCKR::				; LOCK I/O DATABASE FOR READ ACCESS

            50   00000000'EF     9E  003C 26700 	MOVAB	IOC$GL_MUTEX,R0		; GET ADDRESS OF I/O DATA BASE MUTEX

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   8

X01             SCH$LOCKR - LOCK MUTEX FOR READ                                                                                  (1)



                                     0043 26900 	.SBTTL	SCH$LOCKR - LOCK MUTEX FOR READ

                                     0043 27000 ;++

                                     0043 27100 ; FUNCTIONAL DESCRIPTION:

                                     0043 27200 ;	SCH$LOCKR RETURNS TO THE CALLER WHEN NO WRITERS OWN THE

                                     0043 27300 ;	SPECIFIED MUTEX.  THUS THE STRUCTURE PROTECTED BY THE MUTEX

                                     0043 27400 ;	WILL REMAIN UNCHANGED UNTIL THE MUTEX IS RELEASED.  IPL IS

                                     0043 27500 ;	RAISED TO PREVENT AST DELIVERY WHILE THE MUTEX IS OWNED AND

                                     0043 27600 ;	THE PROCESS WILL NOT BE OUTSWAPPED.

                                     0043 27700 ;

                                     0043 27800 ; CALLING SEQUENCE:

                                     0043 27900 ;	BSB/JSB	SCH$LOCKR

                                     0043 28000 ;

                                     0043 28100 ; INPUT PARAMETERS:

                                     0043 28200 ;	R0 - ADDRESS OF MUTEX

                                     0043 28300 ;	R4 - CURRENT PROCESS PCB ADDRESS

                                     0043 28400 ;

                                     0043 28500 ; IMPLICIT INPUTS:

                                     0043 28600 ;	SCH$GQ_MWAIT - MUTEX WAIT QUEUE HEADER

                                     0043 28700 ;	PCB OF CURRENT PROCESS

                                     0043 28800 ;	MUTEX

                                     0043 28900 ;

                                     0043 29000 ; OUTPUTS:

                                     0043 29100 ;	R0-R3 PRESERVED

                                     0043 29200 ;	IPL = ASTDEL

                                     0043 29300 ;

                                     0043 29400 ; IMPLICIT OUTPUTS:

                                     0043 29500 ;	*** TBS ***

                                     0043 29600 ;

                                     0043 29700 ; SIDE EFFECTS:

                                     0043 29800 ;	*** TBS ***

                                     0043 29900 ;

                                     0043 30000 ;--

                                     0043 30100 

                                     0043 30200 SCH$LOCKR::				; LOCK MUTEX FOR READ

                                     0043 30300 	SETIPL	#IPL$_SYNCH		;;; RAISE TO SYNCH IPL

            60            10     E0  0046 30400 	BBS	#MTX$V_WRT,(R0),RDWAIT	;;; WAIT IF WRITE PENDING OR

                          21         0049       

                                     004A 30500 					;;; IN PROGRESS

                          60     B6  004A 30600 	INCW	MTX$W_OWNCNT(R0)	;;; INCREASE OWNER COUNT

         0A A4            0C     91  004C 30700 LKEX:	CMPB	#DYN$C_PCB,PCB$B_TYPE(R4) ; CHECK FOR PCB

                          16     12  0050 30750 	BNEQ	20$			; BUG CHECK IF NOT PCB

                       0E A4     B6  0052 30775 	INCW	PCB$W_MTXCNT(R4)	;;; NOTE IN PCB ALSO

         33 A4            10     91  0055 30800 	CMPB	#16,PCB$B_PRIB(R4)	;;; DONT CHANGE PRIORITY IF

                          09     14  0059 30900 	BGTR	10$			;;; IF REAL TIME

         0B A4            0F     90  005B 31000 	MOVB	#15,PCB$B_PRI(R4)	;;; SET NEW PRIORITY

       0000'CF            0F     90  005F 31100 	MOVB	#15,W^SCH$GB_PRI	;;; AND ANNOUNCE GLOBALLY

                                     0064 31200 10$:	SETIPL	#IPL$_ASTDEL		;;; DROP TO ASTDEL IPL

                                 05  0067 31300 	RSB				;;; AND RETURN

                          008A   31  0068 31350 20$:	BRW	NOTPCB			;

                                     006B 31400 

                                     006B 31500 RDWAIT:					;;; MUST WAIT FOR READ

                       D5 AF     DF  006B 31600 	PUSHAL	SCH$LOCKR		;;; RETRY AFTER WAIT

                                     006E 31700 

                                     006E 31800 WAITM:					;;; WAIT FOR MUTEX TO FREE

                          6E     DD  006E 31900 	PUSHL	(SP)			;;; FORM PC, PSL ON STACK

                       04 AE     DC  0070 32000 	MOVPSL	4(SP)			;;; BUILD PSL

            10            02     F0  0073 32100 	INSV	#IPL$_ASTDEL,#PSL$V_IPL,#PSL$S_IPL,4(SP) ;;; SET IPL TO ASTDEL

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page   9

X01             SCH$LOCKR - LOCK MUTEX FOR READ                                                                                  (1)



         04 AE            05         0076       

         4C A4            50     D0  0079 32200 WAITR:	MOVL	R0,PCB$L_EFWM(R4)	;;; SAVE ADDRESS OF MUTEX

       0000'CF            64     0E  007D 32300 	INSQUE	(R4),W^SCH$GQ_MWAIT	;;; INSERT AT HEAD OF WAIT QUEUE

                     0008'CF     B6  0082 32400 	INCW	W^SCH$GQ_MWAIT+WQH$W_WQCNT	;;; INCREMENT COUNT IN QUEUE

         30 A4            02     B0  0086 32500 	MOVW	#SCH$C_MWAIT,PCB$W_STATE(R4)	;;; SET STATE 

                          FF73'  31  008A 32600 	BRW	SCH$WAITL		;;; WAIT WITH STACK CLEAN, STATE SET

                                     008D 32700 

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  10

X01             SCH$RAVAIL - DECLARE RESOURCE AVAILABILITY                                                                       (1)



                                     008D 32900 	.SBTTL	SCH$RAVAIL - DECLARE RESOURCE AVAILABILITY

                                     008D 33000 

                                     008D 33100 ;++

                                     008D 33200 ; FUNCTIONAL DESCRIPTION:

                                     008D 33300 ;	SCH$RAVAIL IS CALLED TO SIGNAL THE AVAILABILITY OF THE SPECIFIED

                                     008D 33400 ;	RESOURCE AND RELEASE ANY WAITING PROCESSES.

                                     008D 33500 ;

                                     008D 33600 ; CALLING SEQUENCE:

                                     008D 33700 ;	BSB/JSB	SCH$RAVAIL

                                     008D 33800 ;

                                     008D 33900 ; INPUT PARAMETERS:

                                     008D 34000 ;	R0 - RESOURCE NUMBER

                                     008D 34100 ;

                                     008D 34200 ; IMPLICIT OUTPUTS:

                                     008D 34300 ;	*** TBS ***

                                     008D 34400 ;

                                     008D 34500 ; SIDE EFFECTS:

                                     008D 34600 ;	*** TBS ***

                                     008D 34700 ;

                                     008D 34800 ;--

                                     008D 34900 

                                     008D 35000 SCH$RAVAIL::				; DECLARE RESOURCE AVAILABILITY

       0000'CF            50     E7  008D 35100 	BBCCI	R0,W^SCH$GL_RESMASK,EXIT	; CLEAR AND TEST WAITING FLAG

                          61         0092       

                                     0093 35200 	DSBINT	#IPL$_SYNCH		;;; BLOCK SYSTEM EVENTS

                          2B     11  0099 35300 	BRB	UNLOCK			;;; MERGE WITH COMMON CODE

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  11

X01             SCH$IOUNLOCK - UNLOCK I/O DATABASE MUTEX                                                                         (1)



                                     009B 35500 	.SBTTL	SCH$IOUNLOCK - UNLOCK I/O DATABASE MUTEX

                                     009B 35600 ;++

                                     009B 35700 ; FUNCTIONAL DESCRIPTION:

                                     009B 35800 ;	SCH$IOUNLOCK RELEASES OWNERSHIP OF THE I/O DATABASE MUTEX AND

                                     009B 35900 ;	RE-ACTIVATES ANY WAITING PROCESSES IF THE MUTEX HAS BECOME

                                     009B 36000 ;	AVAILABLE AS A CONSEQUENCE OF THIS UNLOCK REQUEST.

                                     009B 36100 ;

                                     009B 36200 ; CALLING SEQUENCE:

                                     009B 36300 ;	BSB/JSB	SCH$IOUNLOCK

                                     009B 36400 ;

                                     009B 36500 ; INPUT PARAMETERS:

                                     009B 36600 ;	R4 - PCB ADDRESS OF CURRENT PROCESS

                                     009B 36700 ;

                                     009B 36800 ; IMPLICIT INPUTS:

                                     009B 36900 ;	SCH$GQ_MWAIT - MUTEXT WAIT QUEUE HEADER

                                     009B 37000 ;	PCB OF CURRENT PROCESS

                                     009B 37100 ;	I/O DATABASE MUTEX

                                     009B 37200 ;

                                     009B 37300 ; IMPLICIT OUTPUTS:

                                     009B 37400 ;	*** TBS ***

                                     009B 37500 ;

                                     009B 37600 ; SIDE EFFECTS:

                                     009B 37700 ;	*** TBS ***

                                     009B 37800 ;

                                     009B 37900 ;--

                                     009B 38000  

                                     009B 38100 SCH$IOUNLOCK::				; UNLOCK I/O DATABASE MUTEX

            50   00000000'EF     9E  009B 38200 	MOVAB	IOC$GL_MUTEX,R0		; GET ADDRESS OF I/O DATABASE MUTEX

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  12

X01             SCH$UNLOCK - UNLOCK MUTEX                                                                                        (1)



                                     00A2 38400 	.SBTTL	SCH$UNLOCK - UNLOCK MUTEX

                                     00A2 38500 ;++

                                     00A2 38600 ; FUNCTIONAL DESCRIPTION:

                                     00A2 38700 ;	SCH$UNLOCK RELEASES OWNERSHIP OF THE SPECIFIED MUTEX AND

                                     00A2 38800 ;	RE-ACTIVATES ANY WAITING PROCESSES IF THE MUTEX HAS BECOME

                                     00A2 38900 ;	AVAILABLE AS A CONSEQUENCE OF THIS UNLOCK REQUEST.

                                     00A2 39000 ;

                                     00A2 39100 ; CALLING SEQUENCE:

                                     00A2 39200 ;	BSB/JSB	SCH$UNLOCK

                                     00A2 39300 ;

                                     00A2 39400 ; INPUT PARAMETERS:

                                     00A2 39500 ;	R0 - MUTEX ADDRESS

                                     00A2 39600 ;	R4 - PCB ADDRESS OF CURRENT PROCESS

                                     00A2 39700 ;

                                     00A2 39800 ; IMPLICIT INPUTS:

                                     00A2 39900 ;	SCH$GQ_MWAIT - MUTEXT WAIT QUEUE HEADER

                                     00A2 40000 ;	PCB OF CURRENT PROCESS

                                     00A2 40100 ;	MUTEX

                                     00A2 40200 ;

                                     00A2 40300 ; IMPLICIT OUTPUTS:

                                     00A2 40400 ;	*** TBS ***

                                     00A2 40500 ;

                                     00A2 40600 ; SIDE EFFECTS:

                                     00A2 40700 ;	*** TBS ***

                                     00A2 40800 ;

                                     00A2 40900 ;--

                                     00A2 41000 

                                     00A2 41100 SCH$UNLOCK::				; UNLOCK MUTEX

                                     00A2 41200 	DSBINT	#IPL$_SYNCH		;;; RAISE TO SYNCH IPL

         0A A4            0C     91  00A8 41250 	CMPB	#DYN$C_PCB,PCB$B_TYPE(R4); STRUCTURE MUST BE PCB

                          47     12  00AC 41275 	BNEQ	NOTPCB			;

                       0E A4     B7  00AE 41300 	DECW	PCB$W_MTXCNT(R4)	;;; NOTE UNLOCK IN PCB

                          0B     12  00B1 41400 	BNEQ	10$			;;; MORE STILL OWNED 

         0B A4         33 A4     90  00B3 41500 	MOVB	PCB$B_PRIB(R4),PCB$B_PRI(R4) ;;; LOWER PRIORITY

       0000'CF         0B A4     90  00B8 41600 	MOVB	PCB$B_PRI(R4),W^SCH$GB_PRI  ;;; AND ANNOUNCE

                          60     B7  00BE 41700 10$:	DECW	MTX$W_OWNCNT(R0)	;;; DECREMENT OWNERSHIP COUNT

                          2F     18  00C0 41800 	BGEQ	EXITN			;;; EXIT IF NOT LAST

            60            10     E7  00C2 41900 	BBCCI	#MTX$V_WRT,(R0),EXITN	;;; EXIT IF NO WRITE IN PROGRESS

                          2B         00C5       

                                     00C6 42000 					;;; OR PENDING

                          11     BB  00C6 42100 UNLOCK:	PUSHR	#^M<R0,R4>		;;; SAVE PCB ADDRESS

            53       0000'CF     DE  00C8 42200 	MOVAL	W^SCH$GQ_MWAIT,R3	;;; GET ADDRESS OF WAIT QUEU

            54            63     D0  00CD 42300 	MOVL	(R3),R4			;;; AND HEAD PCB

            52            02     9A  00D0 42400 	MOVZBL	#PRI$_RESAVL,R2		;;; SET PRIORITY INCREMENT CLASS

            54            53     D1  00D3 42500 10$:	CMPL	R3,R4			;;; CHECK FOR END OF QUEUE

                          17     13  00D6 42600 	BEQL	30$			;;; YES, DONE

         4C A4            6E     D1  00D8 42700 	CMPL	(SP),PCB$L_EFWM(R4)	;;; IS PROCESS WAITING FOR THIS MUTEX

                          0C     12  00DC 42800 	BNEQ	20$			;;; NO, SKIP IT

                          64     DD  00DE 42900 	PUSHL	(R4)			;;; SAVE FLINK

                          FF1D'  30  00E0 43000 	BSBW	SCH$CHSE		;;; CHANGE TO EXECUTABLE STATE

                       08 A3     B7  00E3 43100 	DECW	WQH$W_WQCNT(R3)		;;; DECREASE QUEUE LENGTH

                          10     BA  00E6 43200 	POPR	#^M<R4>			;;; RESTORE FLINK

                          E9     11  00E8 43300 	BRB	10$			;;; AND CONTINUE

            54            64     D0  00EA 43400 20$:	MOVL	(R4),R4			;;; FLINK ON TO NEXT PCB

                          E4     11  00ED 43500 	BRB	10$			;;; AND CONTINUE

                          11     BA  00EF 43600 30$:	POPR	#^M<R0,R4>		;;; RESTORE REGISTERS

                                     00F1 43700 EXITN:	ENBINT				;;; ENABLE INTERRUPTS

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  13

X01             SCH$UNLOCK - UNLOCK MUTEX                                                                                        (1)



                                 05  00F4 43800 EXIT:	RSB				; AND RETURN

                                     00F5 43850 

                                     00F5 43875 NOTPCB:	BUG_CHECK NOTPCB,FATAL		; STRUCTURE NOT PCB

                                     00F9 43900 	.END

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  14

SYMBOL TABLE                                                                                                                     (1)



BIT...         = 0000000F            NOTPCB           000000F5 R     03   PCB$W_BYTLM      00000068            

BUG$_NOTPCB      ********   X   03   PCB$B_ASTACT     0000000C            PCB$W_DIOCNT     00000044            

DYN$C_ACB      = 00000002            PCB$B_ASTEN      0000000D            PCB$W_DIOLM      00000046            

DYN$C_ADP      = 00000001            PCB$B_PRI        0000000B            PCB$W_FILCNT     00000048            

DYN$C_AQB      = 00000003            PCB$B_PRIB       00000033            PCB$W_GPGCNT     00000038            

DYN$C_BRDCST   = 0000001A            PCB$B_TYPE       0000000A            PCB$W_GRP        00000022            

DYN$C_BUFIO    = 00000013            PCB$B_WEFC       00000032            PCB$W_MEM        00000020            

DYN$C_CEB      = 00000004            PCB$C_LENGTH     0000007C            PCB$W_MTXCNT     0000000E            

DYN$C_CRB      = 00000005            PCB$K_LENGTH     0000007C            PCB$W_PPGCNT     0000003A            

DYN$C_CXB      = 0000001B            PCB$L_ASTQBL     00000014            PCB$W_PRCCNT     0000006A            

DYN$C_DDB      = 00000006            PCB$L_ASTQFL     00000010            PCB$W_SIZE       00000008            

DYN$C_DPT      = 0000001E            PCB$L_EFC2P      00000058            PCB$W_STATE      00000030            

DYN$C_FCB      = 00000007            PCB$L_EFC3P      0000005C            PCB$W_TMBU       00000036            

DYN$C_FRK      = 00000008            PCB$L_EFCS       00000050            PCB$W_TQCNT      0000004A            

DYN$C_GSD      = 00000015            PCB$L_EFCU       00000054            PR$_ACCR       = 00000029            

DYN$C_IDB      = 00000009            PCB$L_EFWM       0000004C            PR$_ACCS       = 00000028            

DYN$C_IRP      = 0000000A            PCB$L_OWNER      0000001C            PR$_ASTLVL     = 00000013            

DYN$C_JPB      = 0000001F            PCB$L_PHD        00000064            PR$_ESP        = 00000001            

DYN$C_KFH      = 00000026            PCB$L_PHYPCB     00000018            PR$_ICCS       = 00000018            

DYN$C_KFI      = 00000018            PCB$L_PID        00000060            PR$_ICR        = 0000001A            

DYN$C_LOG      = 0000000B            PCB$L_PQB        0000004C            PR$_IPL        = 00000012            

DYN$C_MTL      = 00000019            PCB$L_SQBL       00000004            PR$_ISP        = 00000004            

DYN$C_MVL      = 00000016            PCB$L_SQFL       00000000            PR$_KSP        = 00000000            

DYN$C_NDB      = 0000001C            PCB$L_STS        00000028            PR$_MAPEN      = 00000038            

DYN$C_NET      = 00000017            PCB$L_UIC        00000020            PR$_NICR       = 00000019            

DYN$C_PBH      = 00000020            PCB$L_WSSWP      00000024            PR$_P0BR       = 00000008            

DYN$C_PCB      = 0000000C            PCB$L_WTIME      0000002C            PR$_P0LR       = 00000009            

DYN$C_PDB      = 00000021            PCB$T_LNAME      0000006C            PR$_P1BR       = 0000000A            

DYN$C_PFL      = 00000023            PCB$V_ASTPEN   = 00000011            PR$_P1LR       = 0000000B            

DYN$C_PIB      = 00000022            PCB$V_BATCH    = 0000000E            PR$_PCBB       = 00000010            

DYN$C_PQB      = 0000000D            PCB$V_DELPEN   = 00000001            PR$_PME        = 0000003D            

DYN$C_PTR      = 00000025            PCB$V_FORCPEN  = 00000002            PR$_RXCS       = 00000020            

DYN$C_RVT      = 0000000E            PCB$V_HIBER    = 00000013            PR$_RXDB       = 00000021            

DYN$C_SFT      = 00000024            PCB$V_INQUAN   = 00000003            PR$_SBIER      = 00000034            

DYN$C_SSB      = 0000001D            PCB$V_LOGIN    = 00000014            PR$_SBIFS      = 00000030            

DYN$C_TQE      = 0000000F            PCB$V_NETWRK   = 00000015            PR$_SBIMT      = 00000033            

DYN$C_TYPAHD   = 00000014            PCB$V_NOACNT   = 0000000F            PR$_SBIQC      = 00000036            

DYN$C_UCB      = 00000010            PCB$V_NODELET  = 00000017            PR$_SBIS       = 00000031            

DYN$C_VCB      = 00000011            PCB$V_PHDRES   = 00000012            PR$_SBISC      = 00000032            

DYN$C_WCB      = 00000012            PCB$V_PSWAPM   = 00000004            PR$_SBITA      = 00000035            

EXIT             000000F4 R     03   PCB$V_PWRAST   = 00000016            PR$_SBR        = 0000000C            

EXITN            000000F1 R     03   PCB$V_RES      = 00000000            PR$_SCBB       = 00000011            

GBL...         = 00000000            PCB$V_RESPEN   = 00000005            PR$_SID        = 0000003E            

IOC$GL_MUTEX     ********   X   03   PCB$V_SSFEXC   = 00000006            PR$_SIRR       = 00000014            

IPL$_ASTDEL    = 00000002            PCB$V_SSFEXCE  = 00000007            PR$_SISR       = 00000015            

IPL$_HWCLK     = 00000018            PCB$V_SSFEXCS  = 00000008            PR$_SLR        = 0000000D            

IPL$_IOPOST    = 00000004            PCB$V_SSFEXCU  = 00000009            PR$_SSP        = 00000002            

IPL$_MAILBOX   = 0000000B            PCB$V_SSRWAIT  = 0000000A            PR$_TBIA       = 00000039            

IPL$_POWER     = 0000001F            PCB$V_SUSPEN   = 0000000B            PR$_TBIS       = 0000003A            

IPL$_QUEUEAST  = 00000006            PCB$V_SWPVBN   = 00000010            PR$_TODR       = 0000001B            

IPL$_SCHED     = 00000003            PCB$V_WAKEPEN  = 0000000C            PR$_TXCS       = 00000022            

IPL$_SYNCH     = 00000007            PCB$V_WALL     = 0000000D            PR$_TXDB       = 00000023            

IPL$_TIMER     = 00000007            PCB$W_APTCNT     00000034            PR$_USP        = 00000003            

LKEX             0000004C R     03   PCB$W_ASTCNT     0000003C            PR$_WCSA       = 0000002C            

MTX$V_WRT      = 00000010            PCB$W_BIOCNT     0000003E            PR$_WCSD       = 0000002D            

MTX$W_OWNCNT     00000000            PCB$W_BIOLM      00000040            PRI$_IOCOM     = 00000001            

MTX$W_STS        00000002            PCB$W_BYTCNT     00000042            PRI$_NULL      = 00000000            

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  15

SYMBOL TABLE                                                                                                                     (1)



PRI$_RESAVL    = 00000002            SCH$LOCKW        00000029 RG    03   

PRI$_TICOM     = 00000004            SCH$LOCKWNOWAIT  00000008 RG    03   

PRI$_TIMER     = 00000002            SCH$RAVAIL       0000008D RG    03   

PRI$_TOCOM     = 00000003            SCH$RWAIT        00000000 RG    03   

PSL$C_EXEC     = 00000001            SCH$UNLOCK       000000A2 RG    03   

PSL$C_KERNEL   = 00000000            SCH$WAITL        ********   X   03   

PSL$C_SUPER    = 00000002            SS$_NORMAL       ********   X   03   

PSL$C_USER     = 00000003            UNLOCK           000000C6 R     03   

PSL$M_CM       = 80000000            WAITM            0000006E R     03   

PSL$M_CURMOD   = 03000000            WAITR            00000079 R     03   

PSL$M_DV       = 00000080            WQH$C_LENGTH     0000000C            

PSL$M_FPD      = 08000000            WQH$K_LENGTH     0000000C            

PSL$M_FU       = 00000040            WQH$L_WQBL       00000004            

PSL$M_IPL      = 001F0000            WQH$L_WQFL       00000000            

PSL$M_IS       = 04000000            WQH$W_WQCNT      00000008            

PSL$M_IV       = 00000020            WQH$W_WQSTATE    0000000A            

PSL$M_PRVMOD   = 00C00000            

PSL$M_SAFBITS  = 000037FF            

PSL$M_TBIT     = 00000010            

PSL$M_TP       = 40000000            

PSL$S_CURMOD   = 00000002            

PSL$S_IPL      = 00000005            

PSL$S_PRVMOD   = 00000002            

PSL$V_CM       = 0000001F            

PSL$V_CURMOD   = 00000018            

PSL$V_DV       = 00000007            

PSL$V_FPD      = 0000001B            

PSL$V_FU       = 00000006            

PSL$V_IPL      = 00000010            

PSL$V_IS       = 0000001A            

PSL$V_IV       = 00000005            

PSL$V_PRVMOD   = 00000016            

PSL$V_TBIT     = 00000004            

PSL$V_TP       = 0000001E            

RDWAIT           0000006B R     03   

SCH$CHSE         ********   X   03   

SCH$C_CEF      = 00000003            

SCH$C_COLPG    = 00000001            

SCH$C_COM      = 0000000C            

SCH$C_COMO     = 0000000D            

SCH$C_CUR      = 0000000E            

SCH$C_FPG      = 0000000B            

SCH$C_HIB      = 00000007            

SCH$C_HIBO     = 00000008            

SCH$C_LEF      = 00000005            

SCH$C_LEFO     = 00000006            

SCH$C_MWAIT    = 00000002            

SCH$C_PFW      = 00000004            

SCH$C_SUSP     = 00000009            

SCH$C_SUSPO    = 0000000A            

SCH$GB_PRI       ********   X   03   

SCH$GL_RESMASK   ********   X   03   

SCH$GQ_MWAIT     ********   X   03   

SCH$IOLOCKR      0000003C RG    03   

SCH$IOLOCKW      00000022 RG    03   

SCH$IOUNLOCK     0000009B RG    03   

SCH$LOCKR        00000043 RG    03   

MUTEX           - MUTEX WAIT ROUTINES                            21-AUG-1978 20:00:35   VAX-11 MACRO X0.3-11               Page  16

PROGRAM SECTION SYNOPSIS                                                                                                         (1)







PROGRAM SECTION SYNOPSIS



.  ABS  .        00000000      00     NOPIC   USR   CON   ABS   LCL NOSHR NOEXE NORD  NOWRT BYTE  

. BLANK .        00000000      01     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  

$ABS$            0000007C      02     NOPIC   USR   CON   ABS   LCL NOSHR   EXE   RD    WRT BYTE  

AEXENONPAGED     000000F9      03     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  





THERE WERE NO ERRORS OR WARNINGS.

19398. BYTES LEFT IN FREE MEMORY POOL.

1492. BYTES OF RECLAIMED MEMORY.

OBJ$:MUTEX,LIS$:MUTEX/-SP=EXECML$/ML,SRC$:MUTEX

3 MLB DIR RDS - 445 GETS TO DEFINE 22 MACROS. 31 INTER. FILE WRITES. 

