From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 21-JUL-1992 15:06:14.60
To:	info-vax@cdclu1.genrad.com
CC:	
Subj:	Re: Tracing mailbox access

This is mostly to say thanks to Bruce A. Hudson of UCIS, Facilities and
Operations, Dalhousie University, Halifax, Nova Scotia, Canada, who described a
method confirming what I'd actually deduced (with only a few system crashes).

I'd also line to thank Michael Clay, Mike (Moroney?) and Carl J Lydick, who at
least gave the problem some thought.

The code I cam up with was ...

	.library	/sys$library:lib.mlb/
	$irpdef
	$ucbdef
ucbaddr:
pid:
	.long	0			; save worrying about argument passing
					; through $CMKRNL. Also makes debugging
					; easier!

	.entry	getreaderpid,^m<>
	movaw	dont_crash,(fp)
	movl	4(ap),r0		; passed mbx_chan by value
	movl	g^ctl$gl_ccbbase,r1	; get channel base
	subl	r0,r1			; now point to required CCB
	movl	(r1),ucbaddr		; extract UCB pointer
	$cmkrnl_s	routin=ucbread	; need inner mode to get UCB fields
	movl	pid,r0
	jsb	g^exe$ipid_to_epid	; make PID into external form
	ret

	.entry	ucbread,^m<r3,r4>
	movaw	dont_crash,(fp)
	movl	ucbaddr,r4
	movl	ucb$l_mb_readqfl(r4),r3	; seems to work on 5.5
	bneq	10$
	movl	ucb$l_irp(r4),r3	; this seems the method for 5.4-3?
	beql	20$
10$:
	movl	irp$l_pid(r3),pid	; easy, innit? actually, this should
					; probably be acb$l_pid, since it's
					; really an ACB, but the offsets to
					; the PID are the same.
	brb	30$
20$:
	clrl	pid			; no luck? so far it's never failed
30$:
	movl	#1,r0			; return SS$_NORMAL always
	ret

	.entry	dont_crash,^m<>
	$exit_s				; s/be $unwind? how far?

	.end
--------------------------------------------------------------------------------
Name : Derek Dongray, Systems Manager, GenRad Ltd.
Phone : 061 486 1511 ext 166
PSS : 234261600119::Dongray                 UKnet : Derek.Dongray@GenRad.co.uk
InterNet : Dongray@cdclu1.GenRad.com        CompuServe : 70374,2745
Address : Monmouth House, Monmouth Road, Cheadle Hulme, Cheshire, SK8 7AY, UK.

