What is a Parity Bit?
Parity is often used in computer hardware error detection. Parity is usually used in data communication to ensure the validity of data. Each device must decide whether it will be used for even parity, odd parity, or non-parity. The sending device adds 1s to each string it sends or decides whether this number is even or odd. It then adds an extra bit, called a check bit, to this string. If even parity is in use, the check digits will set these positions as even numbers; if odd parity is in use, the check digits will set these positions as odd numbers.
- If an odd number of data bits, including the parity bit, are changed during transmission, an error in the parity bit indicates that an error occurred during the transmission. Therefore, the parity bit is an error detection code, but since there is no way to determine which bit is wrong, it cannot perform error correction. When an error occurs, all the data must be discarded, and then the data must be transmitted from the beginning. Successful transmission of data over noisy media can take a long time or even be impossible. But the parity bit also has its advantages. It is the best check code that can be achieved by using one bit of data, and it only needs some XOR gates to generate it. See
- Because of its simplicity, parity bits are used in many computer hardware where it can be re-operated when in trouble or can be very useful with simple error detection. E.g
- For the parity check of the memory, we must start with the concept of bits. A bit is the smallest unit in memory, also called a "bit". It has only two states, which are represented by 1 and 0, respectively. We call 8 consecutive bits a byte. Each byte of non-parity memory has only 8 bits. If one of its bits stores an incorrect value, the corresponding data stored in it will be changed and an application error will occur. The parity check adds an extra bit for each byte (8 bits) for error detection. For example, a certain value (1, 0, 0, 1, 1, 1, 1, 0) is stored in a byte, and each bit is added up (1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 = 5). If the result is odd, the check digit is defined as 1, otherwise it is 0. When the CPU returns to read the stored data, it will add the data stored in the first 8 bits again, and the calculation result is consistent with the check bit. When the CPU finds that the two are different, it makes a certain response. Now the motherboard can use two kinds of memory modules with or without parity bit, but it should be noted that the two types cannot be mixed.
- The above description describes how parity works in a computer. It should be noted that the peripheral device connecting the bus and the I / O bus controller uses an odd parity error checking method. Parity bit checking is not a truly reliable method of error checking, because it can be errorable for both "bits" during transmission. For transmissions inside a personal computer, this possibility is considered negligible. In some mainframe systems, data integrity is very important, and three "bits" are allocated for parity.
- Parity is also used for communication between modems. Here, the parity can be selected to be even (a continuous transmission will form an even number) or odd. The user can also choose to have no parity, which means that the modem has no transmission or parity. When no parity is available (or default), it is assumed to have other forms of parity to detect any errors in the transmission process. The absence of parity usually means that the parity bit can be used for data and transmission acceleration. In cat-to-cat communication, the type of parity is adjusted by the modem that is sent and received before transmission occurs. [1]
- Some redundant disk arrays (en: RAID) use parity blocks for redundancy. If a disk in the array fails, the data blocks in the working disk are used with the parity blocks to reconstruct the lost data.
- Each column below represents a disk, assuming A1 = 00000111, A2 = 00000101, and A3 = 00000000. The XOR of A1, A2, and A3 is equal to 00000010. If the second disk fails, A2 will not be accessible, but it can be rebuilt by XORing A1, A3, and Ap:
- A1 XOR A3 XOR Ap = 00000101
- Redundant disk array
- A1 A2 A3
- Ap B1 B2
- Bp C1 C2
- C3 C4 Cp
- Note: The data block is format A #, and the parity block is Ap. [2-3]