Implements Peterson Leader Election sample algorithm.