An Algebraic Theory for Synchronization