Because of its simplicity, parity is used in many
hardware applications in which an operation can be repeated in case of difficulty, or simply detecting the error is helpful. For example, the
SCSI and
PCI buses use parity to detect transmission errors, and many
microprocessor instruction
caches include parity protection. Because the
Instruction cache data is just a copy of the
main memory, it can be disregarded and refetched if it is found to be corrupted. In
serial data transmission, a common format is 7 data bits, an even parity bit, and one or two
stop bits. That format accommodates all the 7-bit
ASCII characters in an 8-bit byte. Other formats are possible; 8 bits of data plus a parity bit can convey all 8-bit byte values. In serial communication contexts, parity is usually generated and checked by interface hardware (such as a
UART) and, on reception, the result made available to a
processor such as the CPU (and so too, for instance, the
operating system) via a status bit in a
hardware register in the
interface hardware. Recovery from the error is usually done by retransmitting the data, the details of which are usually handled by software (such as the operating system I/O routines). When the total number of transmitted bits, including the parity bit, is even, odd parity has the advantage that both all-zeros and all-ones patterns are detected as errors. If the total number of bits is odd, only one of the patterns is detected as an error, and the choice can be made based on what the more common error is expected to be.
RAID array Parity data is used by RAID arrays (
redundant array of independent/inexpensive disks) to achieve
redundancy. If a drive in the array fails, remaining data on the other drives can be combined with the parity data (using the Boolean
XOR function) to reconstruct the missing data. For example, suppose two drives in a three-drive
RAID 4 array contained the following data: To calculate parity data for the two drives, an XOR is performed on their data: The resulting parity data,
10111001, is then stored on Drive 3. Should any of the three drives fail, the contents of the failed drive can be reconstructed on a replacement drive by subjecting the data from the remaining drives to the same XOR operation. If Drive 2 were to fail, its data could be rebuilt using the XOR results of the contents of the two remaining drives, Drive 1 and Drive 3: as follows: The result of that XOR calculation yields Drive 2's contents.
11010100 is then stored on Drive 2, fully repairing the array. XOR logic is also equivalent to even parity (because
a XOR
b XOR
c XOR ... may be treated as XOR(
a,
b,
c,...), which is an n-ary operator that is true if and only if an odd number of arguments is true). So the same XOR concept above applies similarly to larger RAID arrays with parity, using any number of disks. In the case of a RAID 3 array of 12 drives, 11 drives participate in the XOR calculation shown above and yield a value that is then stored on the dedicated parity drive. Extensions and variations on the parity bit mechanism "double," "dual," or "diagonal" parity, are used in
RAID-DP. == History ==