13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Data modification 171We have seen that data transformations are useful to compress data and to introducesecurity. A third type of transformation is used for reliability. Communication linessuffer from damaged messages for many reasons, depending on the physical nature of theline. Electrical disturbances, such as lightning and nearby power sources, can introducespurious signals. Contention for a shared line can cause competing messages to destroyeach other. The signal may be attenuated over distance to the point that it cannot be reliablydetected. Similarly, bits stored on a disk or a tape might be recorded too faintly, orthe medium might have a small flaw. When they are read back, they may appear differentfrom how they were written. Even bits stored in main store are subject to a lowlevel of error.There is only one mechanism for providing reliability — redundancy, whichmeans using extra bits. This single mechanism takes many forms, depending on thetypes of errors that are expected and their expected frequency. For example, an extra bit,known as the parity bit, can be added to each word in main store. It is set to ensure thatthe total number of one bits in the word is even. (Sometimes odd parity is used instead.They are equivalent in purpose.) <strong>An</strong>y word with a one-bit error will have the wrong parity,which can be detected. Most computers have at least one bit of redundancy in theirmain store for this purpose. If two errors strike the same word, the error will not bedetected. The probability of this event is fairly low. If the probability of double errors isnot low enough, more than one redundant bit can be placed on each word. Now not onlycan one-bit errors be detected, but they can also be corrected on the fly. The correctword is the ‘‘closest’’ good word to the damaged word, where ‘‘closest’’ is measured inHamming distance: the number of bits with different values. Two-bit errors can bedetected but not properly corrected. If n -bit errors are to be detected, legal bit patternsmust not have a Hamming distance of less than n + 1. In general, by adding enoughredundant bits, an error-correcting code can be designed to correct any desired numberof errors. The correct amount of redundancy is the amount that reduces undetected oruncorrected errors to an acceptable level. Main store is often designed to correct singlebiterrors.Parity and its generalizations are also used on devices like tape drives and diskunits. Here the typical error is not a random bit but rather a consecutive string of damagedbits. A method known as the ‘‘cyclic redundancy check,’’ or CRC, calculates theredundant bits to be stored at the end of each chunk of data. This set of bits is oftenknown as a checksum.Checksums and parity bits are usually below the level where the operating systemhas any control. The operating system takes over when a device (including main store)discovers an uncorrectable error. This discovery is usually converted into an interrupt ora trap to the kernel. For devices like tape or disk, the device driver will retry the operationthat failed until either it succeeds or some retry limit is reached. In the latter case,the device is broken (perhaps the tape or disk surface is damaged), and whatever applicationwas trying to use it must be cancelled. The driver might make an entry in a logdetailing the error.For communication devices talking to other computers, retry should eventuallysucceed. The recipient of the damaged message could send a note to the sender requestingretransmission. However, the request for retry might itself be lost, and the recipientmight not even know who the sender is, because that part of the message may have beendamaged. Instead, it is customary for the recipient to acknowledge each undamagedmessage it gets. The sender retransmits any message it has sent that is not acknowledged

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!