Hardware manual

4.6 Flow Control
Flow control means the ability to slow down the flow of bytes in a wire. For serial ports this means the ability
to stop and then restart the flow without any loss of bytes. Flow control is needed for modems and other
hardware to allow a jump in instantaneous flow rates.
Example of Flow Control
For example, consider the case where you connect a 33.6k external modem via a short cable to your serial
port. The modem sends and receives bytes over the phone line at 33.6k bits per second (bps). Assume it's not
doing any data compression or error correction. You have set the serial port speed to 115,200 bits/sec (bps),
and you are sending data from your computer to the phone line. Then the flow from the your computer to your
modem over the short cable is at 115.2k bps. However the flow from your modem out the phone line is only
33.6k bps. Since a faster flow (115.2k) is going into your modem than is coming out of it, the modem is
storing the excess flow (115.2k -33.6k = 81.6k bps) in one of its buffers. This buffer would soon overrun (run
out of free storage space) unless the high 115.2k flow is stopped.
But now flow control comes to the rescue. When the modem's buffer is almost full, the modem sends a stop
signal to the serial port. The serial port passes on the stop signal on to the device driver and the 115.2k bps
flow is halted. Then the modem continues to send out data at 33.6k bps drawing on the data it previous
accumulated in its buffer. Since nothing is coming into this buffer, the number of bytes in it starts to drop.
When almost no bytes are left in the buffer, the modem sends a start signal to the serial port and the 115.2k
flow from the computer to the modem resumes. In effect, flow control creates an average flow rate in the short
cable (in this case 33.6k) which is significantly less than the "on" flow rate of 115.2k bps. This is "start-stop"
flow control.
In the above simple example it was assumed that the modem did no data compression. This could happen
when the modem is sending a file which is already compressed and can't be compressed further. Now let's
consider the opposite extreme where the modem is compressing the data with a high compression ratio. In
such a case the modem might need an input flow rate of say 115.2k bps to provide an output (to the phone
line) of 33.6k bps (compressed data). This compression ratio is 3.43 (115.2/33.6). In this case the modem is
able to compress the 115.2 bps PC-to-modem flow and send the same data (in compressed form) out the
phone line at 33.6bps. There's no need for flow control here so long as the compression ratio remains higher
than 3.43. But the compression ratio varies from second to second and if it should drop below 3.43, flow
control will be needed
In the above example, the modem was an external modem. But the same situation exists (as of early 2003) for
most internal modems. There is still a speed limit on the PC-to-modem speed even though this flow doesn't
take place over an external cable. This makes the internal modems compatible with the external modems.
In the above example of flow control, the flow was from the computer to a modem. But there is also flow
control which is used for the opposite direction of flow: from a modem (or other device) to a computer. Each
direction of flow involves 3 buffers: 1. in the modem 2. in the UART chip (called FIFOs) and 3. in main
memory managed by the serial driver. Flow control protects all buffers (except the FIFOs) from overflowing.
Under Linux, the small UART FIFO buffers are not protected by flow control but instead rely on a fast
response to the interrupts they issue. Some UART chips can be set to do hardware flow control to protect their
FIFOs but Linux (as of early 2003) doesn't seem to support it. FIFO stand for "First In, First Out" which is the
way it handles bytes in a queue. All the 3 buffers use the FIFO rule but only the one in the UART is named
"FIFO". This is the essence of flow control but there are still some more details.
Serial HOWTO
4.6 Flow Control 14