wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

What is Parity and how does it help in detecting errors??

Early computers suffered from a number of "transmission malfunctions". The vacuum tubes which were used to control the electricity flowing through the microswitches frequently broke. Wire connections sometimes got loose. Bugs sometimes landed on exposed wires, splattered, and interfered with data transfer.

In short, if you were storing data, or trying to transfer data, say from RAM to the CPU, you could never be sure that the data that you had was really the correct data.

For example, suppose you looked into RAM and saw the following sequence of switches (using a 7-bit sequence):

Let's assume (just for illustration purposes) that we agreed that whenever we saw this sequence of settings, we agreed that it would represent the letter 'Y', which we would use to mean 'YES'.

At any rate, we send this sequence to the CPU along a Bus (a subsystem that transfers data or power between computer components or between computers). However, when we look inside the CPU, we see the following sequence of switches:

I know that is a little difficult to decipher, so let's go back to our alternative notation:

1 to indicate the switch is 'on'
0 to indicate the switch is 'off'

Here what we had stored in RAM:         0  1  1  1  1  0  0
Here is what we transfer to the CPU:    0  1  1  0  1  0  0

Obviously, there was a problem with the transmission. It may be that the character received by the CPU was actually an 'N', which we agreed would signify 'No' (the opposite of what we intended to send),

So, how can we correct that?

Unfortunately, hardware problems (especially in early computers) were inevitable. We couldn't build perfect machines (we still can't). The best we could hope for was to Detect an error when it occurred.

How can we detect errors?

It is pretty difficult to catch all errors, but there are some tactics which we can apply.

Suppose that we come to an agreement that I will only send you transmissions that have an even number of 'on' switches, or '1' bits (or high bits). When you receive the transmission, you will count the number of '1' bits. If you end up with an even number of '1' bits, you will assume that the message you received is correct. If you receive a message with an odd number of '1' bits, you will know that it is incorrect.

How can we send an 'even' number of 1 bits when the agreed-upon sequence calls for an 'odd' number of 1 bits??

The scheme will only work if we add one additional bit to our sequence of seven bits (which we have been using to represent our character set): The Parity Bit.

By adding 1 additional bit to our seven bit sequence, we can normalize our sequence of bits; we can force the sequence of bits to contain an even (or odd) number of 1 bits.

 How do we do that??

Very simple. Suppose I have two 7-bit sequences, one containing an odd number of 1 bits and another containing an even number of 1-bits. By adding either a '1' or a '0' to the sequence, we can assure that both will contain an even number of '1' bits.

 Original Sequence  Number '1' bits  Parity bit added                New Sequence  Number '1' bits
   0  1  1  0  0  1  0
     3 (odd)
            '1'    0  1  1  0  0  1  0  1 (on 8-bits)        4 (even)
   1  1  1  0  1  1  1       6 (even)             '0'    1  1  1  0  1  1  1  0 (on 8-bits)        6 (even)

So all errors will be detected??

No. Consider the following sequence:

 Original Sequence  Number '1' bits  Parity bit added         Sequence Sent  Sequence Received
   0  1  1  0  1  1  0
     4 (even)
            '0'       0  1  1  0  1  1  0  0      0  0  1  0  0  1  0  0

In the above example the message, the message sent contained 4 1-bits, but the message received contained 2 1-bits. Both contain an evel number of 1-bits, but they are obviously not the same message.

So what good is it??

It may not catch ALL errors, but it is bound to catch most of them. Once an error is detected, we will know that there is a problem.

Is parity always even??

No. It doesn't matter if we use even or odd parity, AS LONG AS WE AGREE HOW TO CONSTRUCT THE SEQUENCE TO BE SENT AND HOW TO ANALYZE THE MESSAGE SENT. Using Odd parity, the sequences used above could be constructed as:

 Original Sequence  Number '1' bits  Parity bit added                New Sequence  Number '1' bits
   0  1  1  0  0  1  0
     3 (odd)
            '0'    0  1  1  0  0  1  0  0 (on 8-bits)        3 (odd)
   1  1  1  0  1  1  1       6 (even)             '1'    1  1  1  0  1  1  1  1 (on 8-bits)        7 (odd)

Notice that transmission errors can still occur using odd parity as easily as they can occur using even parity:

 Original Sequence  Number '1' bits  Parity bit added         Sequence Sent  Sequence Received
   0  1  1  0  1  1  0
     4 (even)
            '1'       0  1  1  0  1  1  0  1      0  0  1  0  0  1  0  1

Is parity still used??

Yes and no. Whenever you boot-up the operating system, One of the diagnostic tests performed before the OS is loaded is a parity check (If the test fails, the system will NOT load, and you WILL cry). In some machines and networks, parity checking is still performed each time a message is sent. In most telecommunications, however, simple parity has been replaced with package switching (a technique in which a stream of data is broken into standardised units called 'packets,' each of which contains address, sequence, control, size and error checking information in addition to the user data. Specialised packet switches operate on this added information to move the packets to their destination in the proper sequence and again present them in a contiguous stream: http://www.probertencyclopaedia.com/SP.HTM), or other techniques.

Some good references include:

  1. Parity (Whatis.com)
  2. Parity Checking
  3. Memory parity errors

At this point in time, you should be able to Answer the following questions:

  1. Why was parity developed?

    Early computers suffered from a number of "transmission malfunctions". The vacuum tubes which were used to control the electricity flowing through the microswitches frequently broke. Wire connections sometimes got loose. Bugs sometimes landed on exposed wires, splattered, and interfered with data transfer. Parity was a scheme used to help detect errors
     
  2. How does parity work?

    A parity bit (either a '0' or a '1') is added to the sequence of bits before transmission to make the total number of '1' bits either even or odd.
     
  3. Which is better: Even or odd parity?

    It doesn't matter whether we use even or odd parity as long as we agree beforehand which scheme to use
     
  4. Can all errors be detected? What are some examples?

    No, errors can still occur. For Example (assume we are using ODD parity):
     
     Original Sequence  Number '1' bits  Parity bit added         Sequence Sent  Sequence Received
       0  1  0  1  0  1  0
         3 (even)
                '0'      0  1  0  1  0  1  0  0      0  0  0  0  0  1  0  0

    In this example, the message sent is NOT the message received, but it would not be detected since the total number of '1' bits received is odd.
     

  5. Is parity still used?

    Yes and no. Whenever you boot-up the operating system, One of the diagnostic tests performed before the OS is loaded is a parity check (If the test fails, the system will NOT load). In some machines and networks, parity checking is still performed each time a message is sent. In most telecommunications, however, simple parity has been replaced with other techniques
     
  6. Which of the following is true about parity?

    a.  It alters a bit sequence in such a way as to make the total number of '1' bits even or odd
    b.   It is still used but is not as common as it once was
    c.   It has been replaced by other techniques such as package switching
    d.   A and B
    e.   A and C

    Answer: b
     
  7. Which of the following is NOT true about parity?

    a.  It has been replaced by other techniques such as package switching
    b.   It adds a bit to the existing bit sequence to make the total number of '1' bits even or odd
    c.   It is still used but is not as common as it once was
    d.   Transmission errors can still occur
    e.   Even and odd parity work equally as well

    Answer: a
     
  8. Which of the followwing is an example of odd parity?

    a.  10011001
    b.   00010001
    c.   10100111
    d.   01101100
    e.   00100001

    Answer: c
     
  9. Which of the followwing is an example of even parity?

    a.  10010001
    b.   00110001
    c.   10111001
    d.   01101100
    e.   00110001

    Answer: d
     

    This page was last updated on 01/08/05