Kernel Patch to Improve Serial Line Response Time

Gene H. Olson gene at digibd
Tue Dec 5 13:32:50 AEST 1989


Enclosed find an "adb" patch for UNIX-pc version 3.51a.

                     BACKGROUND
                     ----------

I noticed that the response time to keystrokes on my UNIX-pc
was not as good as I have come to expect from terminals and
other systems.   I poked around a bit and found the cause.

In the Kernel, there is a routine called "serscan" which moves
data (this is conjecture) from the raw interrupt queue to the
raw input queue.  As it turns out, "serscan" (apparently) is
only called by the "clock" routine, and only every 4 clock TICs.

This 4 clock delay causes up to a 4/60 second variation in
keystroke echo times which is quite noticeable to some people.
(Me for example).

The following "adb" patch changes the "clock" routine to call
"serscan" every TIC instead,  improving both instant response
time and improving consistency.

Some extra CPU time is taken with the extra call.  I found on
my system that CPU intensive benchmarks took .3% longer.  This
decrease in performance was not noticeable of course, and it is
well worth it to a crackpot like myself.

*WARNING* +----------------------------------------------------------+
*WARNING* |             ***** DISCLAIMER *****                       |
*WARNING* |                                                          |
*WARNING* |  If you do this and blow it, you have just corrupted     |
*WARNING* |  your UNIX kernel and may wind up reloading your system  |
*WARNING* |  from scratch.  Make a backup copy of /unix before       |
*WARNING* |  beginning so you can copy it back if necessary.         |
*WARNING* |                                                          |
*WARNING* |  You may wish to patch the in-core version of UNIX       |
*WARNING* |  first so you can try it out before altering your        |
*WARNING* |  permanent version of /unix.                             |
*WARNING* |                                                          |
*WARNING* |  You take personal responsibility for any patches to     |
*WARNING* |  your kernel;  you will have no-one to blame but         |
*WARNING* |  yourself if you lose or corrupt data.                   |
*WARNING* |                                                          |
*WARNING* +----------------------------------------------------------+

--------------- Log of ADB session begins here --------------
---------------      # comments added          --------------
# adb -w unix

##### Check out a portion of the Clock
##### interrupt routine.
#####
##### Note that it calls "serscan" only after "fserscan"
##### is incremented to 4, so "serscan" is called only
##### every 4 clock tics.

clock+250,10?ia
clock+250:		tst.b	serinprogress
clock+256:		bne.b	clock+26a
clock+258:		tst.l	serbufcnt
clock+25e:		beq.b	clock+26a
clock+260:		mov.l	c.w(%fp),(%sp)
clock+264:		jsr	serrint
clock+26a:		and.w	&-701,sr
clock+26e:		mov.b	fserscan,%d0
clock+274:		addq.b	&1,fserscan
clock+27a:		cmp.b	&2,%d0
clock+27e:		ble.b	clock+28c
clock+280:		clr.b	fserscan
clock+286:		jsr	serscan
clock+28c:		tst.l	idleflag
clock+292:		beq.b	clock+2ae
clock+294:		tst.b	runin
clock+29a:

##### Change the compare so we test "fserscan" against
##### 0 instead of 2.  Now we call "serscan" every 2
##### clock tics.

clock+27c?x
clock+27c:	2

.?w 0
clock+27c:	2	=	0

##### Change the "ble" to a "blt", so now we call "serscan"
##### every clock tic.

clock+27e?x
clock+27e:	6f0c

.?w 6d0c
clock+27e:	6f0c	=	6d0c

##### Check our work.  Note that the intent of the original
##### code is preserved.  If you wish to slow the scan back
##### down, you can still do it by patching clock+27c.

clock+250,10?ia
clock+250:		tst.b	serinprogress
clock+256:		bne.b	clock+26a
clock+258:		tst.l	serbufcnt
clock+25e:		beq.b	clock+26a
clock+260:		mov.l	c.w(%fp),(%sp)
clock+264:		jsr	serrint
clock+26a:		and.w	&-701,sr
clock+26e:		mov.b	fserscan,%d0
clock+274:		addq.b	&1,fserscan
clock+27a:		cmp.b	&0,%d0
clock+27e:		blt.b	clock+28c
clock+280:		clr.b	fserscan
clock+286:		jsr	serscan
clock+28c:		tst.l	idleflag
clock+292:		beq.b	clock+2ae
clock+294:		tst.b	runin
clock+29a:
_________________________________________________________________
   __
  /  )                  Gene H. Olson            uunet!digibd!gene
 / __  _  __   _        DigiBoard Inc.
(__/ _(/__//__(/_       St. Louis Park, MN       (612) 922-8055



More information about the Unix-pc.sources mailing list