Hardware manual

only by that port. Thus the FIFO waits until it has received a number of bytes and then issues an interrupt.
However, this interrupt will also be sent if there is an unexpected delay while waiting for the next byte to
arrive (known as a timeout). Thus if the bytes are being received slowly (such as from someone typing on a
terminal keyboard) there may be an interrupt issued for every byte received. For some UART chips the rule is
like this: If 4 bytes in a row could have been received in an interval of time, but none of these 4 show up, then
the port gives up waiting for more bytes and issues an interrupt to fetch the bytes currently in the FIFO. Of
course, if the FIFO is empty, no interrupt will be issued.
Each interrupt conductor (inside the computer) has a number (IRQ) and the serial port must know which
conductor to use to signal on. For example, ttyS0 normally uses IRQ number 4 known as IRQ4 (or IRQ 4). A
list of them and more will be found in "man setserial" (search for "Configuring Serial Ports"). Interrupts are
issued whenever the serial port needs to get the CPU's attention. It's important to do this in a timely manner
since the buffer inside the serial port can hold only 16 incoming bytes. If the CPU fails to remove such
received bytes promptly, then there will not be any space left for any more incoming bytes and the small
buffer may overflow (overrun) resulting in a loss of data bytes.
There is no Flow Control to prevent this.
Interrupts are also issued when the serial port has just sent out all of its bytes from its small transmit FIFO
buffer out the external cable. It then has space for 16 more outgoing bytes. The interrupt is to notify the CPU
of that fact so that it may put more bytes in the small transmit buffer to be transmitted. Also, when a modem
control line changes state, an interrupt is issued.
The buffers mentioned above are all hardware buffers. The serial port also has large buffers in main memory.
This will be explained later
Interrupts convey a lot of information but only indirectly. The interrupt itself just tells a chip called the
interrupt controller that a certain serial port needs attention. The interrupt controller then signals the CPU. The
CPU then runs a special program to service the serial port. That program is called an interrupt service routine
(part of the serial driver software). It tries to find out what has happened at the serial port and then deals with
the problem such a transferring bytes from (or to) the serial port's hardware buffer. This program can easily
find out what has happened since the serial port has registers at IO addresses known to the serial driver
software. These registers contain status information about the serial port. The software reads these registers
and by inspecting the contents, finds out what has happened and takes appropriate action.
4.5 Data Flow (Speeds)
Data (bytes representing letters, pictures, etc.) flows into and out of your serial port. Flow rates (such as 56k
(56000) bits/sec) are (incorrectly) called "speed". But almost everyone says "speed" instead of "flow rate".
It's important to understand that the average speed is often less than the specified speed. Waits (or idle time)
result in a lower average speed. These waits may include long waits of perhaps a second due to Flow Control.
At the other extreme there may be very short waits (idle time) of several micro-seconds between bytes. If the
device on the serial port (such as a modem) can't accept the full serial port speed, then the average speed must
be reduced.
Serial HOWTO
4.4 Interrupts 13