Exact GPS simulation with logarithmic complexity, and its application to an optimally fair scheduler