What are locks?

# 16 What are locks? What are UARTs? How do they affect performance?

Contents of this section

UARTs (Universal Asyncronous Receiver Transmitter) are chips inside your communication devices (terminal, serial card). There is one on each end of a connection. Their purpose is to convert data (bytes) to bits, send each bit down the serial line, and then rebuild the data again on the other end. The UARTs are asyncronous devices, because the time interval between transmission of data is not fixed. UARTs deal with data in byte size pieces.

Say you have a terminal hooked up to your PC. When you type a character, the terminal presents it to it's UART. The UART shifts that character (a byte) out onto the serial line one bit at at time, at a specific rate. Hence, we have the rates 110, 300, 1200, 2400, ... bits/sec (bps). This is simply a measure of how fast bits are being sent. On the other end, the receiving UART takes all the bits and rebuilds the character (byte).

There are several different types of UARTs. You have probably heard of dumb UARTs - the 8250 and 16450, and smart or FIFO UARTs - the 16550A. To understand their differences, first let's examine what happens when a UART has sent or received a byte.

The UART itself can't do anything with the data, it just sends and receives it. The CPU gets an interrupt every time a byte has been sent or received. The CPU then moves a received byte out of the UART's register and into memory somewhere, or gives the UART another byte to send. The 8250 and 16450 UARTs only have a 1 byte buffer. That means, that every time 1 byte is sent or received, it interrupts the CPU. At low rates, this is OK. But, at high transfer rates, the CPU get so busy dealing with the UART, that is doesn't have time to tend to other tasks. In some cases, the CPU does not get around to servicing the interrupt in time, and the byte is overwritten, because they are coming in so fast.

That's where the 16550A UARTs come in. These chips come with 16 byte FIFOs. This means that it can receive or transmit up to 16 bytes before it has to interrupt the CPU. Not only can it wait, but the CPU then can transfer all 16 byte at a time. Although the interrupt threshold is seldom set at 16, this is still a significant advantage over the other UARTs, which only have the 1 byte buffer. The CPU receives less interrupts, and is free to do other things. Data is not lost, and everyone is happy.

In general, the 8250 and 16450 UARTs should be fine for speeds up to 19200 bps. After 19200, you might start seeing data loss, and a reduction in computing speed.

Keep in mind that these dumb UART types are not bad, they just aren't good for high speeds. You should have no problem connecting a terminal, or a mouse to these UARTs. But, for a high speed modem, the 16550A is definately a must.

You can buy serial cards with the 16550A UARTs for a little more money, just ask your dealer what type of UART is on the card. Or if you want to upgrade your existing card, you can simply purchase 16550A chips and replace your existing 16450 UARTs. They are pin-to-pin compatible. Some cards come with socketed UARTs for this purpose, if not you can solder. Note, that you'll probably save yourself a lot of trouble by just getting a new card :-).

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter