Page 1 of 1

parities and error checking

Posted: Mon Sep 29, 2008 2:33 pm
by xDDunce
ok, so in my computing class at college, we have just started doing binary and hex etc. im way ahead of my class :lol: although we have just moved onto parities and error checking when sending messages within a computer but what i was wondering was: Are parities done automaticly by the CPU or should they be built-in to the kernel to ensure all messages are correct?

I am also interested in if anyone knows how to to find if there is an error with the parity bits? all we have touched on is error checking when the error is in the actual data rather than the parities, mainly because there is a higher possibility of that to get an error.

hope this all makes sense. if not i can explain. it isn't difficult really.

Thanks in advance,

James.

Re: parities and error checking

Posted: Mon Sep 29, 2008 4:26 pm
by Combuster
Are parities done automaticly by the CPU or should they be built-in to the kernel to ensure all messages are correct?
Within a computer, signals are stable enough not to get corrupted in any way (imagine your code randomly changing!) However media external to the computer may not necessarily be. CDs can be scratched, floppies dislike magnets, network cables can pick up noise. What you have to do about these things depends on how they work. Some may not give you corrupt data at all, some will check and correct the data for you, and only for the remaining set will you have to check the data's integrity yourself.
I am also interested in if anyone knows how to to find if there is an error with the parity bits? all we have touched on is error checking when the error is in the actual data rather than the parities, mainly because there is a higher possibility of that to get an error.
The problem with such scheme is that with one parity unit you can never detect the location of the error - you can always change exactly one of the units in the set at will to make the set appear correct again.
Also, if you know the location of the error, you can attempt to fix it as well, making anything of that sort no longer error checking, but rather error correction.

Try the following scheme with parity bits (one of the simplest forms of error correction):

Code: Select all

0 1 1 0 1 1 0 0 | 0
1 0 1 0 1 0 0 1 | 0
1 1 1 0 0 0 1 1 | 1
----------------+--
0 0 1 0 0 1 1 0 | 1 
Now if there's exactly one bit off, you can locate it:

Code: Select all

0 1 1 0 1 1 0 0 | 0 <- ok
1 0 1 0 1 0 0 1 | 0 <- ok
1 1 1 0 0 0 1 1 | 1 <- ok
----------------+--
0 0 1 0 1 1 1 0 | 1 <- wrong
v v v v X v v v   v
By checking each row and column, you can detect which lines are wrong, and therefore, where the error must lie. In this case, one of the parity bits was accidentally set:

Code: Select all

        |       |   <- ok
        |       |   <- ok
        v       |   <- ok
------>(1)<-----|-- <- wrong
v v v v X v v v   v
Note that when there are too many errors, you can not recover, or even find the wrong answer:

Code: Select all

0 1 1 0 1 1 0 0 | 0 <- ok
1 0 1 0 1 0 0 1 | 0 <- ok
1 1 1 1!1!0 1 1 | 1 <- ok
----------------+--
0 0 1 1!0 1 1 0 | 1 <- wrong
v v v v X v v v   v
Of course, there are many alternative, more complex, and more effective algorithms around.

Re: parities and error checking

Posted: Mon Sep 29, 2008 5:23 pm
by bewing
And if you really do want to check parities, the x86 cpu automatically calculates the parity of the result of every calculation. So you can test parity at any time you want.
Combuster wrote: Within a computer, signals are stable enough not to get corrupted in any way (imagine your code randomly changing!)
Of course, that is a slight overgeneralization. One reason that your computer crashes every 8 months is precisely because an unfriendly gamma ray trashed an important bit in a program.

Re: parities and error checking

Posted: Tue Sep 30, 2008 8:40 am
by xDDunce
so, in conclusion, it would just be time consuming to run the checks everytime i send a signal anyway. and when it comes to making multimedia drivers, it would be worth my while to implement it?

thanks for the detailed reply combuster, that cleared things up alot.

and to bewing, thanks for the extra knowledge. i never knew gamma rays could do that! :lol:

thanks again,

James.