From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  3-MAR-1992 23:05:10.02
To:	ARISIA::EVERHART
CC:	
Subj:	MWAIT V1.06, part 6 of 7

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA21193; Tue, 3 Mar 92 22:35:58 EST
Message-Id:  <9203040335.AA21193@crdgw1.ge.com>
Received: From SUN2.NSFNET-RELAY.AC.UK by CRVAX.SRI.COM with TCP; Tue,  3 MAR 92 17:32:39 PST
Received: from ncdlab.ulcc.ac.uk by sun2.nsfnet-relay.ac.uk via JANET 
          with NIFTP id <3509-8@sun2.nsfnet-relay.ac.uk>;
          Tue, 3 Mar 1992 08:49:06 +0000
Date: Tue, 3 Mar 92 8:27 GMT
From: Nick de Smith <NICK@ncdlab.ulcc.ac.uk>
To: INFO-VAX <@nsfnet-relay.ac.uk:INFO-VAX@KL.SRI.com>
Subject: MWAIT V1.06, part 6 of 7

-+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
X----------------
X
XRWMBX is generally effected by the setting of the process resource wait mode
V.
XDisabling resource wait mode will cause $QIOs to return an error message rat
Vher
Xthan going into RWMBX.
X
Xa. "Process resource wait is DISABLED"
X   "Process resource wait is ENABLED"
X   "Process is marked for deletion"
X`09These are information only messages about the state of the process.
X
Xb. "Attempt to write w. bytes to devu: on channel c
X    Messages: m., Quota (bytes): Initial: q., Remaining: r."
X`09The process has gone into RWMBX due to an attempt to write "w" bytes
X`09to the device "devu:" on channel number "c". The device already has
X`09"m" messages in it waiting to be read (excluding this write attempt).
X`09The device was created with an initial buffer quota of "q" bytes, of
X`09which "r" bytes remain. "r" should be less than "w" for this wait state
X`09to occur. The process will remain in this state until sufficient space
X`09is made in the device (at least "w" bytes). Note that the device need
X`09not be a mailbox - it could be any device that "looks like" a mailbox
X`09to VMS.
X
X
X3. Table of JIB wait states
X---------------------------
XA JIB wait state is represented by the process state being MWAIT, and the EF
VN
Xwait mask containing the address ofthe process's JIB. The location JIB$B_FLA
VGS
Xthen contains a number of bits representing different reasons for the wait.
XJIB waits are generally effected by the setting of the process resource wait
Xmode. Disabling resource wait mode will cause $QIOs to return an error messa
Vge
Xrather than going into an MWAIT state.
X
XText`09Description
X-------`09-----------
XJ????`09Unknown JIB wait state
XJIBYT`09At least one process in the job tree is waiting for BYTCNT quota
XJITQE`09''   ''   ''    ''   ''  ''  ''  ''  ''    ''    '' TQELM    ''
XJBYTQ`09Both BYTCNT and TQELM quotas are both exhausted. At least one proces
Vs
X`09in the job tree is waiting for each quota.
X
XA number of messages may be displayed if the process is in a JIB resource
Xrelated wait in an attempt to further isolate the problem. JIB waits are for
Xresources that are shared by ALL processes in a job tree.
X
Xa. "Process resource wait is DISABLED"
X   "Process resource wait is ENABLED"
X   "Process is marked for deletion"
X`09These are information only messages about the state of the process.
X
Xb. "Job buffered I/O count exhausted
X    (Requested: 'r'. bytes, Available: 'c'. bytes, Quota: 'q'.)"
X`09A request has been made for 'r' bytes of buffered byte count quota.
X`09There is a byte count quota of 'c' bytes remaining (BYTCNT) from an
X`09initial quota value of 'q' (BYTLM). The value 'c' is not enough to
X`09satisfy the request being made, and the process has been placed into a
X`09JIB wait until more quota is available. In some cases the amount of
X`09quota requested, 'r', may not be determinable and thus will not be
X`09displayed.
X`09The UAF parameter BYTLM and/or the SYSGEN parameters
X`09PQL_DBYTLM/PQL_MBYTLM need to be increased.
X
Xc. "Job open file count exhausted (FILCNT zero)"
X`09The UAF parameter FILLM and/or the SYSGEN parameters
X`09PQL_DFILLM/PQL_MFILLM need to be increased.
X
Xd. "Job timer count exhausted (TQCNT: 'c'., TQLM: 'q'.)"
X`09There are 'c' timers left for this job (should be 0 here)
X`09from an initial quota of 'q'.
X`09The UAF parameter TQELM and/or the SYSGEN parameters
X`09PQL_DTQELM/PQL_MTQELM need to be increased.
X`09
Xe. "Job page file space exhausted (PGFLCNT zero)"
X`09The UAF parameter PGFLQUOTA and/or the SYSGEN parameters
X`09PQL_DPGFLQUOTA/PQL_MPGFLQUOTA need to be increased.
X
X
X
X4. Table of known system MUTEXs.
X-------------------------------
XA system MUTEX is represented by the process state being RSN$_MWAIT, and the
V EFN
Xwait mask containing the address of the mutex. MWAIT will identify the the
Xmutex from the following table which is taken from table 8.3 in the V5.2
XInternals an Data Structures Manual (IDSM) and other sources. You will need
V to
Xuse the IDSM to determine the precise cause of any of these wait states.
X
X
XText`09Mutex address`09`09Description
X-------`09-------------`09`09-----------
XMLogNm`09LNM$AL_MUTEX`09`09Shared logical name structures.
XMIOdb`09IOC$GL_MUTEX`09`09I/O database access.
XMCEB`09EXE$GL_CEBMTX`09`09Common event block list. Used by the CEB
X`09`09`09`09handling code to synchronise access to the
X`09`09`09`09CEB listhead, SCH$GQ_CEBHD and SCH$GW_CEBCNT.
XMSMP`09SMP$GL_CPU_MUTEX`09SMP access.
XMPgDyn`09EXE$GL_PGDYNMTX`09`09Paged dynamic memory list.
XMGSD`09EXE$GL_GSDMTX`09`09Global section descriptor list.
XMACL`09EXE$GL_ACLMTX`09`09(*)
XMEnq`09EXE$GL_ENQMTX`09`09(*)
XMShMGS`09EXE$GL_SHMGSMTX`09`09Shared memory global section descriptor table.
XMShMMb`09EXE$GL_SHMMBMTX`09`09Shared memory mailbox descriptor table.
XMCIA`09CIA$GL_MUTEX`09`09System intruder lists.
XMBsVMS`09EXE$GL_BASIMGMTX`09Loadable executive image data structures. Used
X`09`09`09`09by LDR$LOAD_IMAGE to synchronise access to the
X`09`09`09`09the executive loadable image lists for loading,
X`09`09`09`09unloading and initialisation.
XMQMan`09QMAN$GL_MUTEX`09`09Queue manager. I can't find anywhere that uses
X`09`09`09`09this mutex.
XMWAIT?`09`09`09`09Unknown MWAIT state. The address of the MUTEX is
X`09`09`09`09given in the "Wait mask" field.
X
X(*) Means "Not currently used".
X
X`5Bend`5D
$ CALL UNPACK MWAIT.TXT;1 1479362716
$ create 'f'
X;+
X; MWAIT_MACROS
X;
X; Author`09: Nick de Smith
X; Creation date`09: 09-Dec-91
X;
X; Description
X;
X;`09MACROs to support the MWAIT utility.
X;
X; Notes
X;
X; Edit`09Edit date`09By`09Why
X;  02`0909-Jan-92`09NMdS`09Add in action routine to RWPC
X;  01`0909-Dec-91`09NMdS`09New
X;-
X
X;
X; BxxxW`09`5Bsource,`5D destination
X;
X; Same as the VAX branch instruction, except that they allow a word offset.
X;
X.macro`09blbcw`09src, dest, ?label
X`09blbs`09src, label
X`09brw`09dest
X label:
X.endm
X
X.macro`09beqluw`09dest, ?label
X`09bnequ`09label
X`09brw`09dest
X label:
X.endm
X
X.macro`09bgtruw`09dest, ?label
X`09blequ`09label
X`09brw`09dest
X label:
X.endm
X
X.macro`09blssuw`09dest, ?label
X`09bgequ`09label
X`09brw`09dest
X label:
X.endm
X
X.macro`09SCH`09list
X .macro`09SCH_ENTRY`09name, ?label
X  .address s'label
X  .save_psect
X  .psect`09$text`09pic, shr, rd, nowrt, noexe, byte
X  s'label:`09.ascic`09"'name'"
X  .restore_psect
X .endm
X .irp`09name, <list>
X SCH_ENTRY`09name
X .endr
X.endm
X
X.macro`09MTX`09list
X .macro`09MTX_ENTRY`09addr, name, ?label
X  .iif`09different <addr>, <-1>, .weak addr
X  .long`09addr
X  .address s'label
X  .save_psect
X  .psect`09$rodata`09pic, shr, rd, nowrt, noexe, byte
X  s'label:`09.ascic`09"'name'"
X  .restore_psect
X .endm
X .irp`09entry, <list>
X MTX_ENTRY`09entry
X .endr
X.endm
X
X.macro`09RWPC`09start, offset, text, action=0, backoff=0, ?label
X  .address s'label
X  .long`09start
X  .long offset
X  .long backoff
X  .long`09action
X  .save_psect
X  .psect`09$rodata1 pic, shr, rd, nowrt, noexe, byte
X  s'label:`09.ascid`09"'text'"
X  .restore_psect
X.endm
X;
X; $PUSH`09<arg>
X;
X; Internal macro to push an argument onto the stack.
X;
X; If the argument is not an address expression then
X;`09PUSHL`09arg
X; else
X;`09if the register is the PC then
X;`09`09PUSHAL`09arg
X;`09else
X;`09`09PUSHL`09arg
X;`09endif
X; endif
X;
X.macro`09$push`09arg
X`09.ntype`09$$$mode arg
X$$$mode = $$$mode@-4&`5Exf
X$$$addr = 1`09`09`09; Assume address
X.iif equal $$$mode  , $$$addr=0`09; If literal..
X.iif equal $$$mode-1, $$$addr=0`09; ..immediate..
X.iif equal $$$mode-5, $$$addr=0`09; ..or register
X.if  equal $$$addr
X`09pushl`09arg
X.if_false
X`09.ntype`09$$$mode arg
X$$$reg = $$$mode&`5Exf
X`09.if  equal $$$reg-`5Exf
X`09`09pushal`09arg
X`09.if_false
X`09`09pushl`09arg
X`09.endc
X.endc
X.endm
X;
X; PRINTF`09format=<fao-format-string>,arg1,...
X;
X; This is a nice macro to FAO format according to the passed string and data
V.
X; $printf is a variant where the format parameter is the address of an ASCID
X; control string.
X;
X.macro`09printf`09format, p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15
V,p16,p17,?l
X`09.save_psect
X`09.psect`09$text
Xt'l:`09.ascid`09"'format'"
X`09.restore_psect
X`09$printf`09t'l',<p1>,<p2>,<p3>,<p4>,<p5>,<p6>,<p7>,<p8>,<p9>,<p10>,<p11>,<
Vp12>,<p13>,<p14>,<p15>,<p16>,<p17>
X.endm
X
X.macro`09$printf`09faoctl, p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p1
V5,p16,p17
X`09pushr`09#`5Em<r0,r1>`09`09; Save R0 and R1
X`09subl`09#8, sp`09`09`09; Allocate some space for a descriptor
X`09movl`09sp, r0`09`09`09; R0 => allocated descriptor
X`09clrq`09(r0)`09`09`09; Initialise the descriptor as dynamic
X`09movb`09#DSC$K_DTYPE_T, DSC$B_DTYPE(r0)
X`09movb`09#DSC$K_CLASS_D, DSC$B_CLASS(r0)
X$$$cnt = 0
X$$$arg = 0
X.irp`09$arg, <p17,p16,p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>
X.if not_blank $arg
X$$$cnt = $$$cnt + 4
X$$$arg = 1
X`09$push`09$arg
X.endc
X.endr
X.iif not_equal $$$arg, pushal (sp)`09; Address of argument list (if any)
X`09pushaq`09(r0)`09`09`09; Address of output descriptor
X`09clrl`09-(sp)`09`09`09; No returned length address
X`09pushaq`09faoctl`09`09`09; Address of format control string
X`09calls`09#<3+$$$arg>, g`5ELIB$SYS_FAOL
X.iif not_equal $$$arg, addl #$$$cnt, sp
X`09pushaq`09(sp)`09`09`09; Address of the output string...
X`09calls`09#1, g`5ELIB$PUT_OUTPUT`09; ...print the string
X`09pushaq`09(sp)
X`09calls`09#1, g`5ESTR$FREE1_DX`09; ...and de-allocate it
X`09addl`09#8, sp`09`09`09; Release the allocated descriptor
X`09popr`09#`5Em<r0,r1>`09`09; Restore R0 and R1
X.endm
X
X;
X; PRINT`09<text>
X;
X; Outputs a string of text to the screen
X;
X.macro`09print`09text, ?l
X`09.save_psect
X`09.psect`09$text
Xt'l:`09.ascid`09"'text'"
X`09.restore_psect
X`09pushaq`09t'l
X`09calls`09#1, g`5ELIB$PUT_OUTPUT
X.endm
X; end
$ CALL UNPACK MWAIT_MACROS.MAR;1 893942448
$ create 'f'
X/*
X Program`09: TEST0
X Author`09`09: Nick de Smith
X Date`09`09: 09-Dec-91
X
X This program makes the process go into an MWAIT state by creating a mailbox
V and then
X writing to it until the process's BIO count is exhausted. We do this to tes
Vt the
X MWAIT utility.
X
X Usage:`09$ spawn/nowait run test0
X`09$ run mwait
X*/
X
X#include`09descrip
X#include`09psldef
X#include`09stsdef
X#include`09ssdef
X#include`09iodef
X
X#define`09ss_check( command ) `7B`09`09`09\
X`09long`09l_status = (command);`09`09\
X`09if ( (l_status & STS$M_SUCCESS) == 0 ) `7B \
X`09`09LIB$SIGNAL( l_status );`09`09\
X`09`7D`09`09`09`09`09\
X`7D
X
X#define`09MBX_MSGMAX`0910`09`09`09`09`09`09/* Maximum size of a message`09`0
V9*/
X#define`09MBX_BUFQUO`09(MBX_MSGMAX * 200)`09`09`09`09/* Ammount of buffering
V to allow`09*/
X
X#define`09MBX_WRITE_SIZE`091`09`09`09`09`09`09/* Size of messages to write`0
V9`09*/
X
XMWAIT_TEST()
X`7B
X`09$DESCRIPTOR( mbx$x_name, "MWAIT_BOX" );
X`09short`09mbx$w_chan;`09`09`09`09`09`09/* Mailbox channel`09`09`09*/
X`09long`09mbx$l_efn = 0;`09`09`09`09`09`09/* Mailbox I/O event flag`09`09*/
X`09char`09mbx$t_buffer`5B MBX_MSGMAX `5D;`09`09`09`09/* Mailbox read buffer`
V09`09`09*/
X`09short`09mbx$q_iosb`5B 4 `5D;
X
X`09ss_check( SYS$CREMBX(`09`09`09`09`09`09/* Create logging mailbox`09`09*/
X`09`090`09`09,`09`09`09`09`09/* Mailbox is temp`09`09`09*/
X`09`09&mbx$w_chan`09,`09`09`09`09`09/* Channel number returned here`09`09*/
X`09`09MBX_MSGMAX `09,`09`09`09`09`09/* Maximum size of message`09`09*/
X`09`09MBX_BUFQUO`09,`09`09`09`09`09/* Buffer quota`09`09`09`09*/
X`09`090`09`09,`09`09`09`09`09/* Protection mask`09`09`09*/
X`09`09PSL$C_USER`09,`09`09`09`09`09/* User mode access`09`09`09*/
X`09`09&mbx$x_name`09) )`09`09`09`09`09/* Mailbox name`09`09`09`09*/
X
X`09for ( ;; ) `7B`09`09`09`09`09`09`09/* Until we run out of quota...`09`09*
V/
X`09`09ss_check( SYS$QIO(
X`09`09`09mbx$l_efn`09,`09`09`09`09/* Use our own event flag`09`09*/
X`09`09`09mbx$w_chan`09,`09`09`09`09/* Channel to use`09`09`09*/
X`09`09`09IO$_WRITEVBLK`09,`09`09`09`09/* Write console channel`09`09*/
X`09`09`09mbx$q_iosb`09,`09`09`09`09/* I/O status block`09`09`09*/
X`09`09`090`09`09,`09`09`09`09/* QIO AST address`09`09`09*/
X`09`09`090`09`09,`09`09`09`09/* QIO AST parameter`09`09`09*/
X`09`09`09mbx$t_buffer`09,`09`09`09`09/* P1 = Message buffer`09`09`09*/
X`09`09`09MBX_WRITE_SIZE`09,`09`09`09`09/* P2 = Size of buffer`09`09`09*/
X`09`09`090`09`09,`09`09`09`09/* P3`09`09`09`09`09*/
X`09`09`090`09`09,`09`09`09`09/* P4`09`09`09`09`09*/
X`09`09`090`09`09,`09`09`09`09/* P5`09`09`09`09`09*/
X`09`09`090`09`09) )`09`09`09`09/* P6`09`09`09`09`09*/
X`09`7D
X
X`09return`09SS$_NORMAL;`09`09`09`09`09`09/* Return success to caller`09`09*/
X`7D
X`0C
$ CALL UNPACK TEST0.C;1 1732389033
$ create 'f'
X/*
X Program`09: TEST1
X Author`09`09: Nick de Smith
X Date`09`09: 09-Dec-91
X
X This program makes the process go into a JIB related wait by exhausting the
V timer
X queue entry quota for the process. We do this to test the MWAIT utility.
X
X Usage:`09$ spawn/nowait run test1
X`09$ run mwait
X*/
X
X#include`09stsdef
X#include`09ssdef
X
X#define`09ss_check( command ) `7B`09`09`09\
X`09long`09l_status = (command);`09`09\
X`09if ( (l_status & STS$M_SUCCESS) == 0 ) `7B \
X`09`09LIB$SIGNAL( l_status );`09`09\
X`09`7D`09`09`09`09`09\
X`7D
X
X#define`09TIMER_SECONDS`09100`09`09`09`09`09`09/* Number of seconds to run t
Vimers for`09*/
X
XTIMER_TEST()
X`7B
X`09unsigned long l_efn = 0;`09`09`09`09`09/* Use event flag 0`09`09`09*/
X`09unsigned long q_daytim`5B`5D = `7B TIMER_SECONDS * -10000000, -1 `7D;`09/
V* Delta time for timer`09`09`09*/
X`09unsigned long l_reqidt = 0;
X`09void`09(*ap_astadr)() = 0;`09`09`09`09`09/* AST routine address`09`09`09*
V/
X
X`09SYS$SETRWM( 0 );`09`09`09`09`09`09/* 0 = wait for resource when it expire
Vs */
X
X`09for ( ;; ) `7B`09`09`09`09`09`09`09/* Until we run out of quota...`09`09*
V/
X`09`09ss_check( SYS$SETIMR(
X`09`09`09l_efn`09`09,`09`09`09`09/* Event flag number to use`09`09*/
X`09`09`09q_daytim`09,`09`09`09`09/* Time to wait`09`09`09`09*/
X`09`09`09ap_astadr`09,`09`09`09`09/* AST address (not used)`09`09*/
X`09`09`09l_reqidt++`09,`09`09`09`09/* Use different request id each time`09*
V/
X`09`09`090`09`09) )`09`09`09`09/* Flags: <0> = 0, use elapsed time`09*/
X`09`7D
X
X`09return`09SS$_NORMAL;`09`09`09`09`09`09/* Return success to caller`09`09*/
X`7D
$ CALL UNPACK TEST1.C;1 56100730
$ create 'f'
X/*
X Program`09: TEST2
+-+-+-+-+-+-+-+-  END  OF PART 6 +-+-+-+-+-+-+-+-

