From: almesber@nessie.cs.id.ethz.ch (Werner Almesberger) Subject: Experimental polling serial lines driver Date: Sun, 3 May 1992 16:39:11 GMT
I've written a little experimental serial lines driver that solves
the interrupt sharing problem when using more than two ports. It
does this by polling the UARTs at a regular interval instead of
waiting for interrupts.
How it works: additional timer interrupts are generated and on
each interrupt all active serial ports are checked for new data
or whether more data can be sent on them. All other routines that
depend on timer interrupts are called at the usual rate (HZ).
This approch has the following advantages:
- UARTs don't have to generate interrupts.
- the interrupt rate is limited.
- the code is much simpler.
- hardware-handshake is trivial to implement.
Unfortunately, there are some disadvantages:
- some CPU time (usually > 5%, depending on CPU type, clock,
etc.) is wasted.
- turn-around times are slightly increased.
The current implementation adds some additional disadvantages,
like hard-coding of the highest baud rate in the kernel.
Modified files:
kernel/chr_drv/serial.c new polling driver
kernel/sched.c support for sub-jiffies
kernel/sys_call.S removed counting of jiffies
The number of additional timer interrupts is controlled by SPEED_UP
in sched.c. The minimum value of SPEED_UP is max_bps/1000, where
max_bps is the highest baud rate that has to be supported.
Increasing the value of SPEED_UP makes the driver less sensitive to
interrupt latency but makes the entire system slower and may cause
interrupt latency problems for other devices.
I'm using a value of 6 for reliable operation at 4800 bps on a loaded
386DX/25 and a value of 10 for sometimes unreliable operation at 9600
bps on an otherwise idle system. A 386DX/33 or a 486 may have enough
power to achieve reliable operation at 9600 bps (or maybe even 19200
bps) with higher speed-up values.
A possible source of problems might be the choice of UART base addres-
ses. The kernel uses 3f8,2f8,3e8,2e8. My PC has them at 3f8,2f8,2e8,
2e0. Others may use yet another set of addresses. They're defined in
kernel/chr_drv/tty_io.c.
This driver is experimental and hasn't been tuned for performance. I
wouldn't recommend it for regular use. However, if the UARTs support
hardware queues (e.g. 16550A), the SPEED_UP value might be lowered
so much that the waste of CPU time becomes neglegible. Using such
features will require some changes to the driver.
Known problems:
Setting big SPEED_UP values will crash the system.
Accessing non-existent serial devices may create endless streams
of pseudo data and slow the system. (The driver tries to detect
this.)
DSR detection may hang a serial line if it fails.
There have been occasional lockups. Don't know whether they are
still there. Opening the same port from another process seems to
resolve the problem.
A uuencoded tar.Z file with the necessary changes to the pre-0.96
kernel source is appended to this message.
- Werner
============================== cut here ==============================
begin 644 serial.n.tar.Z
M'YV0<\K(21.&C8LQ`!(J7,BPH<.'$"-*G$@1`(B+-FC0`&'QXD48'#U^#"GR
MXHP;,VQ<K"$#1@R7,FC$B''Q)8T;,BS"J,BSI\^?0`'4F4,GC)R+`.2\>4,G
MZ$.E3)U*G4JUJM6K6'F^4*$`A(J+;-*XJ8/GQ1J!;LJP>1%P8,EZO2BE
M#!PV8<:4F0-"+!V!<NK`H=."S$`[9=R`:$N03=\W(,3D`0'G#9NP;LZXB/M"
M@8(18L>PJ4.F#`@>F,F^H$,GCPLT/CR#=B.:M&D>8>:T89N':)DVKV//KEWZ
M=.[=:=X$]_RYM!FQIHTDD3*%RI<I1:0D"<($1$;F1,/023.FKQLZBP5^23/G
MRQLXB4'T``&#Q="]7\C,.3H?Q@[F=KR1!AGIN<6&>_"Y@4(=;LR1QAEI$>@7
M")B5D8(">W3ET81BY%;&?QI>U&%`\H'`6AY?%"4&&V5L4>$*TE%G'7;:<=>%
M"W*4$0897\31@@]DB!?&?R*E808(*(@EQA=PH#!B&2O4D()\_>%AAAE3YDA'
M'7*X0:1'HJ6!0@I?7O1&'70LV>0,+#RYP@QDA@C"F6DRB<(-;7JX`@UQ%NF&
MFDYZV*='][6G'W](%IK??B"8`((?*-#$`P\40I?"E'P@J:2=;MHPI:,PX-$2
M"#^`("FE%8*@@YP?#7H146*Z6N!Z[;T7'Q_SG5II6O_U`:"`!#)6$).6L8%"
M@`->F*%(1`4V!GHG]EA'&=-ZE>..TE);!@LJW#'07]E.6Z9YT+;&0ANYK9%G
M0"R$M^4<+)@QVAQHL'!'&&>-.P8:1H&P+X@BH3O'&B7&,*X9;QR%PHDEQEC=
M==EMQ\0.)K9V&@@.SQ@Q=RLX(07$-3(Q!<4GKK#"E!DF8"22;=&*8'R."KP&
MR@HD(-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1D>ZTE\N^*='
M?>ISJ/K5=:3U7YO^]*A/O>I7S_K6N_[UL(^][&=/^]K;_O:XS[WN=\_[WOO^
M]\`/OO"'3_SB&__XR$^^\I?/_.8[__G0C[[TIT_]ZEO_^MC/OO:WS_WN>__[
%X`__]P&'
`
end
-- _________________________________________________________________________ / Werner Almesberger, ETH Zuerich, CH almesber@nessie.cs.id.ethz.ch / / IFW A44 Tel. +41 1 254 7213 almesberger@rzvax.ethz.ch / /_BITNET:_ALMESBER@CZHETH5A__HEPNET/CHADNET:_[20579::]57414::ALMESBERGER_/