*BSD News Article 32802


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!agate!msuinfo!harbinger.cc.monash.edu.au!yarrina.connect.com.au!warrane.connect.com.au!kralizec.zeta.org.au!not-for-mail
From: bde@kralizec.zeta.org.au (Bruce Evans)
Newsgroups: comp.os.386bsd.questions
Subject: Re: How many serial on FreeBSD
Date: 16 Jul 1994 19:14:35 +1000
Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis v.42bis
Lines: 58
Message-ID: <3088dr$6ah@kralizec.zeta.org.au>
References: <3012rg$b5@beyond.demon.co.uk>
NNTP-Posting-Host: kralizec.zeta.org.au

In article <3012rg$b5@beyond.demon.co.uk>,
Steve O'Hara-Smith <steveo@beyond.demon.co.uk> wrote:
>	Realistically how many AST 4 style serial ports can be used with
>FreeBSD on a 486DX2/66 using 16550A UARTS at 19,200 or 38,400 before
>interrupt latency causes lost data ? Anyone know ?

In theory, about 4 AST4's at 38400 bps.  Only one at 115200 bps.  Maybe
less if you fast DMA devices.

At 38400 bps , the 16 char fifo in a 16550 allows for about

	15 * 1000000 / 3840 = 3906 usec

of latency.  If you don't have any fast DMA devices, then there is
nothing in FreeBSD to get in the way of the serial interrupt handler
running except the serial interrupt handler itself.  It can handle a
single char in 10-20 usec even if it has to take an interrupt per
char.  Assume (almost) the worst case of taking 20 usec each handle 15
bytes of input, 15 bytes of output, 15 modem status interrupts and 15
line status interrupts during the latency time.  The maximum number of
ports is

	3906 / 20 / 15 / 4 = 3 = 3/4 of 1 AST 4port.

This estimate is very conservative.  In practice, under heavy loads the
driver will handle multiple events per interrupt and take only 5-10 usec
per event, and there usually won't be any modem status events or line
status events, so a better estimate is

	3906 / 10 / 15 / 2 = 13 = 3+3/4 AST 4port's.

The driver could be cleverer about reducing latency for multiple ports
It could read only 1 char at a time from each port read from all ports
before handling any other events.  This would eliminate the factors of
15 and (4 or 2) in the above calculations at the cost of a small increase
in the factor of (20 or 10) and increase the conservative estimate to
90 ports.  However, other problems would stop 90 ports from working
continuosly at full speed.

The serial overhead for handling 38400 bps in both directions at once is
about 3% for the multiport version of sio (2% for the non-multiport
version), so if you have 13 ports in full use it will take 39% of the
system.  You probably wouldn't want more, and my want a much lower
average.  However, full use is probably rare so 16 ports is probably
practical.

If you have busmastering SCSI controllers or other fast DMA devices,
then many of the 3906 usec in the above calculations will be stolen for
DMA and the maximum number of ports must be reduced to match.  The
exact number stolen depends on the configuration of the controller and
the speed of the attached devices.  3906 is so large that it is
probably accurate to use the average number of cycles stolen.  My
Ultrastor 34F SCSI controller sometimes seems to steal up to 250 cycles
at a time.  This is very bad for unbuffered UARTs.  However, on the
average it only steals a few at a time (the disk speed is limited) and
3906 is large enough to hide a few 250's.
-- 
Bruce Evans  bde@kralizec.zeta.org.au