Some clock functions to implement loops of fixed length.