Previous Next Contents

14. One step further...

This section is not required reading, but may give you some further insight into Unix, and the world of telecommunications.

14.1 What are lock files?

Lock file are simply a file saying that a particular device is in use. They are kept in /usr/spool/uucp, or /var/lock. Linux lock files are named LCK..name, where name is either a device name, or a UUCP site name. Certain processes create these locks so that they can have exclusive access to devices, for instance if you dial out on your modem, a lock will appear telling other processes that someone is using the modem already. Locks mainly contain the PID of the process that has locked the device. Most programs look at the lock, and try to determine if that lock is still valid by checking the process table for the process that has locked the device. If the lock is found to be valid, the program (should) exit. If not, some programs remove the stale lock, and use the device, creating their own lock in the process. Other programs just exit and tell you that the device is in use.

14.2 ``baud'' vs. ``bps''

``baud'' and ``bps'' are perhaps one of the most misused terms in the computing/telecom field. Many people use these terms interchangeably, when in fact they are not!

baud

The baud rate is a measure of how many times per second the signal sent by a modem (modulator-demodulator) changes. For example, a baud rate of 1200 implies one signal change every 833 microseconds. Common baud rates are 50, 75, 110, 300, 600, 1200, and 2400. Most high speed modems run at 2400 baud. Because of the bandwidth limitations on voice-grade phone lines, baud rates greater than 2400 are harder to achieve, and only work under very pristine phone line quality. ``baud'' is named after Emile Baudot, the inventor of the asynchronous telegraph printer.

bps

The bps rate is a measure of how many bits per second are transmitted. Common bps rates are 50, 75, 110, 300, 1200, 2400, 9600, ... 115200. With modems using V.42bis compression (4:1 compression), theoretical bps rates are possible up to 115200. This is what most people mean when they misuse the word ``baud''.

So, if high speed modems are running at 2400 baud, how can they send 14400 bps? The modems achieve a bps > baud rate by encoding a number of bits per baud. Thus, when 2 or more bits are encoded per baud, the bps rate exceeds the baud rate. If your modem connects at 14400 bps, it's going to be sending 6 bits per baud.

How did this confusion start? Well, back when today's low speed modems were yesterday's high speed modems, the bps rate actually did equal the baud rate. One bit would be encoded per baud. People would use bps and baud interchangeably, because they were the same number. For example, a 300 bps modem also had a baud rate of 300. This all changed when faster modems came around, and the bit rate exceeded the baud rate.

14.3 ``baud'' vs. ``bps''What are UARTs? How do they affect performance?

UARTs (Universal Asyncronous Receiver Transmitter) are chips on your PC serial card. Their purpose is to convert data to bits, send the bits down the serial line, and then rebuild the data again on the other end. UARTs deal with data in byte sized pieces, which is conveniently also the size of ASCII characters.

Say you have a terminal hooked up to your PC. When you type a character, the terminal gives that character to it's transmitter (also a UART of some sort). The transmitter sends that byte out onto the serial line, one bit at a time, at a specific rate. On the PC end, the receiving UART takes all the bits and rebuilds the byte and puts it in a buffer.

There are two different types of UARTs. You have probably heard of dumb UARTs - the 8250 and 16450, and 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 from the serial device every time a byte has been sent or received. The CPU then moves the received byte out of the UART's buffer 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, the CPU is interrupted. At low rates, this is OK. But, at high transfer rates, the CPU gets 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 are useful. 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 bytes 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. (There is also a 16550 UART, but it is treated as a 16450)

In general, the 8250 and 16450 UARTs should be fine for speeds up to 38400 bps. At speeds greater than 38400 bps, you might start seeing data loss, and a reduction in interactive response time. Other PC operating systems (definition used loosely here), like DOS aren't multitasking, so they might be able to cope better with 8250 or 16450s. That's why some people don't see data loss, until they switch to Linux.

Non-UART, and intelligent multiport boards use DSP chips to do additional buffering and control, thus relieving the CPU even more. For example, the Cyclades Cyclom, and Stallion EasyIO boards use a Cirrus Logic CD-1400 RISC chip.

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 definitely 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, if you've got the money, they are under US$ 50.

14.4 What's the real difference between the /dev/cuaN and /dev/ttySN devices?

The only difference is the way that the devices are opened. The dialin devices /dev/ttySN are opened in blocking mode, until CD is asserted (ie someone connects). So, when someone wants to use a /dev/cuaN device, there is no conflict with a program watching the /dev/ttySN device.

The distinction is made to allow dialin and dialout use of the same serial port.


Previous Next Contents