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


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 20 SEP 88 18:01:34 PDT
Received: from RELAY.CS.NET by KL.SRI.COM with TCP; Tue, 20 Sep 88 17:58:51 PDT
Received: from relay2.cs.net by RELAY.CS.NET id ah21293; 20 Sep 88 15:07 EDT
Received: from merrimack.edu by RELAY.CS.NET id ad21211; 20 Sep 88 14:42 EDT
Date: Tue, 20 Sep 88 14:44 EDT
From: "Rand P. Hall" <RAND%merrimack.edu@RELAY.CS.NET>
Subject: Getting IPL$_SYNC code to run under SMP
To: info-vax@KL.SRI.COM
X-VMS-To: IN%"info-vax@kl.sri.com"

Not being an internals guru I am having difficulty getting kernel mode
code to run under SMP.

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

