From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP 24-SEP-1988 12:55
To:	ARISIA::EVERHART
Subj:	Re: Getting IPL$_SYNC code to run under SMP


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 23 SEP 88 04:57:30 PDT
Received: from Xerox.COM by KL.SRI.COM with TCP; Fri, 23 Sep 88 04:34:47 PDT
Received: from Burger.ms by ArpaGateway.ms ; 22 SEP 88 19:11:05 PDT
Sender: "James_A._Gray.OsbuSouth"@Xerox.COM
Date: 22 Sep 88 19:10:31 PDT (Thursday)
Subject: Re: Getting IPL$_SYNC code to run under SMP
From: "James_A._Gray.OsbuSouth"@Xerox.COM
To: RAND%merrimack.edu@RELAY.CS.NET
cc: info-vax@KL.SRI.COM
In-Reply-to: "RAND%merrimack.edu%RELAY.CS.NET":GV:Xerox's message of
 21-September-88 (Wednesday) 4:57:35 PDT
Message-ID: <880922-191105-3671@Xerox>

Mr. Hall asks:

The following code segment (courtesy of Jamie Hanrahan) fetches 4
longwords of system performance data. Would someone care to describe
the process of turning this code into something that will run on an
SMP machine? I've read the section on turning IPL$_SYNC code into code
that uses spinlocks in the Device Support manual but it was, of
course, over my head. Would anyone care to translate?...........Rand

	.title	sample

	.library	/sys$library:lib.mlb/
	$ipldef
	$pcbdef
	$phddef


	.psect	code	pic,nowrt,shr,long
	.entry	sample,	^m<r8>
	movl	ap, r8				;preserve the AP
	$cmkrnl_s	routin=smpl             ;do SMPL in kernel mode
	movl	#ss$_normal, r0
	ret


; This is the actual cmkrnl routine code that gets the data:
;    sys-wide faults, hard faults, system page faults, inswaps

	.entry	smpl,	^m<r8>
	movl	r8,ap				; restore AP
	movl	4(ap),r2			; set first address pointer
	dsbint	#IPL$_SYNCH			; (ensure no changes during
						;   data collection)
	movl	G^PMS$GL_FAULTS, (r2)+		; get number of faults sys-wide
  	movl	G^PMS$GL_PREADIO, (r2)+		; get disk reads due
                                                ;   to page faults
	moval	G^MMG$AL_SYSPCB, R4		; R4 -> System PCB
      	movl	PCB$L_PHD(R4), R4		; R4 -> System PHD
	movl	PHD$L_PAGEFLTS(R4), (r2)+	; get system page fault count
	movl	G^SWP$GL_ISWPCNT, (r2)	       	; inswaps since boot
	enbint
	movl	#ss$_normal, r0
	ret
	.end


To answer your question, change the routine smpl to that shown below.  The only
real changes are to change DSBINT to LOCK and to change ENBINT to UNLOCK.  Note
the use of the new IPL for performance monitoring.

	Jim Gray	(Gray:OSBUSouth@Xerox.COM:Xerox)



	.entry	smpl,	^m<r8>
	movl	r8,ap				; restore AP
	movl	4(ap),r2			; set first address pointer
	LOCK	LOCKNAME=PERFMON,-	; (ensure no changes during
		LOCKIPL=IPL$_PERFMON,-	;   data collection)
		SAVIPL=-(SP),-
		PRESERVE=NO
	movl	G^PMS$GL_FAULTS, (r2)+		; get number of faults sys-wide
  	movl	G^PMS$GL_PREADIO, (r2)+		; get disk reads due
                                                ;   to page faults
	moval	G^MMG$AL_SYSPCB, R4		; R4 -> System PCB
      	movl	PCB$L_PHD(R4), R4		; R4 -> System PHD
	movl	PHD$L_PAGEFLTS(R4), (r2)+	; get system page fault count
	movl	G^SWP$GL_ISWPCNT, (r2)	       	; inswaps since boot
	UNLOCK	LOCKNAME=PERFMON,-
		NEWIPL=(SP)+,-
		CONDITION=RESTORE,-
		PRESERVE=NO
	movl	#ss$_normal, r0
	ret
	.end

