2 square pulses -- how to ID when they separate?

I'd like to use the Arduino to monitor two square wave pulses (0 volts for about 2ms, then 5 volts for about 2ms, repeating...). Normally, those two pulses are almost perfectly harmonized (i.e., leading and falling edges of both signals "virtually" simultaneous), but occasionally one will shift ahead a smidge, so that the leading edge of one occurs maybe 50us before the other. Any thoughts on an elegant way to detect when the pulses shift apart like that? Can I use a separate external interrupt for each signal, or would the fact that they normally rise and fall at virtually the same time make the results unpredictable? Or is there an established hardware approach for doing this?

Does it matter which one shifts? Or is it only important to know when they are not in sync?

How soon after they get out of sync do you need to know?

A PLL(phase locked loop) hardware might help.

Or is there an established hardware approach for doing this?

XOR gate feeding a flip flop, possibly with some filtering if in the normal state the difference is enough to clock the FF.


Rob

PaulS:
Does it matter which one shifts? Or is it only important to know when they are not in sync?

How soon after they get out of sync do you need to know?

Thanks all for the thoughts so far.

The actual frequency of both pulses will vary over time, but they will normally stay in sync. When they get out of sync, it will always be the same signal that is ahead of the other. It is not important how quickly it gets detected/flagged, although sometimes they might be out of sync for as short as 50ms and I'd still like to detect that, even if the detection occurs after the signals are back in sync.

If you feed the signal that ends up loading to an interrupt pin, with CHANGE, and the other into another pin on the same port, you can use direct port manipulation techniques to read both pins at the same time. If they are different, there is an out-of-sync condition.