[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MiNT 1.11 BETA: optimize loadavg calculation



ARRGGHHH, i should have tested it before posting :-(
Of course, the registers have to be saved before calling
checkbttys_vbl. Here is a new patch for intr.spp, the rest is ok.

Andreas.

--- orig/intr.spp	Mon Aug  8 05:01:36 1994
+++ intr.spp	Tue Aug 16 19:28:56 1994
@@ -35,29 +35,23 @@
 	XREF	_leave_kernel
 	XREF	_preempt
 	XREF	_in_kernel
-	XREF	_uptime_vbl
+	XREF	_calc_load_average
 	XREF	_uptimetick
+	XREF	_checkbttys_vbl
 
 ; AKP: this code is hit once every 5ms; it updates the time fields of curproc.
 _mint_5ms:
 	move.l	a0,-(sp)
-	lea	_uptimetick,a0
-	tst.l	(a0)
-	bne.s	L_no_uptime
-	move.l	#200,(a0)
-L_no_uptime:
-	subq.l	#1,(a0)
+	subq.w	#1,_uptimetick
 	move.l	_curproc,a0
 	tst.w	_in_kernel
 	bne.s	L_systime
-	lea	P_USRTIME(a0),a0	; get offset to curproc->usrtime
-	addq.l	#5,(a0)			; update the time
+	addq.l	#5,P_USRTIME(a0)	; update curproc->usrtime
 	move.l	(sp)+,a0
 	move.l	_old_5ms+8,-(sp)	; branch to old vector
 	rts
 L_systime:
-	lea	P_SYSTIME(a0),a0	; get offset to curproc->systime
-	addq.l	#5,(a0)
+	addq.l	#5,P_SYSTIME(a0)	; update curproc->systime
 	move.l	(sp)+,a0
 	move.l	_old_5ms+8,-(sp)
 	rts
@@ -83,7 +77,11 @@
 
 L_comeback:
 	movem.l	d0-d2/a0-a2,-(sp)	; save C registers
-	jsr	_uptime_vbl		; Go test if it's time to update uptime
+	jsr	_checkbttys_vbl
+	tst.w	_uptimetick
+	bgt.s	L_no_uptime
+	jsr	_calc_load_average	; Go test if it's time to update uptime
+L_no_uptime:
 	movem.l	(sp)+,d0-d2/a0-a2
 	tst.w	_proc_clock		; has time expired yet?
 	beq.s	L_expired		; yes -- maybe go switch processes
@@ -136,8 +134,7 @@
 _reset:
 	move.w	#$2700,sr		; avoid interruption here
 	move.l	sp,_init_tail		; save A7
-	lea	_init_tail,sp		; set up temporary stack
-	lea	256(sp),sp
+	lea	_init_tail+256,sp	; set up temporary stack
 	movem.l	d0-d2/a0-a2,-(sp)	; save C registers
 	jsr	_restr_intr		; restore interrupts
 	movem.l	(sp)+,d0-d2/a0-a2	; restore registers