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

a few small BIOS IO patches :-)



1. just wondered again why gettys on BIOS devices constantly take CPU
while on vts they dont...  here is an improvement:

Index: bios.c
--- bios.c_	Tue Jul 27 18:51:48 1993
+++ bios.c	Sat Oct  9 03:47:22 1993
@@ -165,7 +165,14 @@
 		k = keyrec;
 again:
 		while (k->tail == k->head) {
+#if 1
+	/* make blocking reads eat less CPU...
+	   (keyboard input is not so fast so should be ok.)
+	*/
+			nap(60);
+#else
 			yield();
+#endif
 		}
 
 		if (checkkeys()) goto again;
@@ -178,11 +185,21 @@
 		return r;
 	}
 	else {
+		unsigned long tick = *((long *)0x4baL);
+
 		if (dev == AUXDEV && has_bconmap)
 			dev = curproc->bconmap;
 
 		if (dev > 0) {
 			while (!BCONSTAT(dev)) {
+#if 1
+	/* make blocking (for longer) reads eat less CPU...
+	   if yield()ed > 2 seconds and still no cookie continue with nap
+	*/
+				if ((*((unsigned long *)0x4baL) - tick) > 400)
+					nap(60);
+				else
+#endif
 				yield();
 			}
 		}

 (you still can see huge CPU usage now but only when the system would
otherwise be idle, thats because when no process is ready to run MiNT
wakes up nap()ing ones early...  so you could say the cycle eating is
still there but now reduced to _very_ low priority.)

2. auto-repeat on console doesn't generate keyboard interrupts and so
a select on the keyboard usually did not wake up before the key was
released (or timeout).  this was the reason for the often sluggish
response on vts...

Index: intr.spp
--- intr.spp_	Tue Aug 17 11:11:20 1993
+++ intr.spp	Sat Oct  9 14:05:34 1993
@@ -60,6 +60,9 @@
 	move.l	_old_timer+8,-(sp)	; jump to GEMDOS time vector
 	rts
 
+	XREF	_kintr
+	XREF	_keyrec
+
 _mint_vbl:
 %ifndef ONLY030
 	tst.w	($59e).w		; test longframe (AKP)
@@ -73,6 +76,11 @@
 	rts
 
 L_comeback:
+	move.w	d0,-(sp)		; `repeated' keys don't generate
+	move.w	_keyrec+8,d0		; interrupts...  check buffer and
+	cmp.w	_keyrec+6,d0		; set hi byte of kintr so that
+	sne	_kintr			; select can wake up before you
+	move.w	(sp)+,d0		; release the key, etc.
 	tst.w	_proc_clock		; has time expired yet?
 	beq.s	L_expired		; yes -- maybe go switch processes
 L_out:

3. and while i was at it... :)  here is a patch for the ^S (stopc)
`lockup' on serial ports, not a nice one but better than nothing...
(and allow reads generate SIGQUIT too.)

Index: tty.c
--- tty.c_	Tue Aug 17 11:11:32 1993
+++ tty.c	Sat Oct  9 15:54:36 1993
@@ -703,6 +703,10 @@
 				killgroup(curproc->pgrp, SIGTSTP);
 			else if (c == tty->tc.t_intrc)
 				killgroup(curproc->pgrp, SIGINT);
+#if 1
+			else if (c == tty->tc.t_quitc)
+				killgroup(curproc->pgrp, SIGQUIT);
+#endif
 			else if (c == tty->tc.t_stopc)
 				tty->state |= TS_HOLD;
 			else if (c == tty->tc.t_startc)
@@ -784,8 +788,38 @@
 
 	if (mode & COOKED) {
 		tty->state |= TS_COOKED;
-		while (tty->state & TS_HOLD)
+		while (tty->state & TS_HOLD) {
+#if 1
+	/* hack: BIOS devices != console never reset TS_HOLD themselves
+	   unless another process happens to call tty_getchar on them while
+	   we're here.  someone has a better fix? :-(  -nox
+	*/
+/* BIOS device definitions */
+#define CONSDEV 2
+			short bdev;
+			extern DEVDRV bios_tdevice;
+
+			if (f->dev == &bios_tdevice &&
+			    (bdev=f->fc.aux) != CONSDEV && bconstat(bdev)) {
+				long c = bconin(bdev) & 0x7fffffffL;
+
+				if (c == UNDEF)
+					;	/* do nothing */
+				else if (c == tty->ltc.t_suspc) {
+					tty->state &= ~TS_HOLD;
+					killgroup(tty->pgrp, SIGTSTP);
+				} else if (c == tty->tc.t_intrc) {
+					tty->state &= ~TS_HOLD;
+					killgroup(tty->pgrp, SIGINT);
+				} else if (c == tty->tc.t_quitc) {
+					tty->state &= ~TS_HOLD;
+					killgroup(tty->pgrp, SIGQUIT);
+				} else if (c == tty->tc.t_startc)
+					tty->state &= ~TS_HOLD;
+			}
+#endif
 			nap(60);	/* sleep for 60 milliseconds */
+		}
 	}
 	else
 		tty->state &= ~TS_COOKED;

 happy patching...
	Juergen
-- 
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
								...ohne Gewehr
PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA