Stability and deadlock avoidance in distributed systems for traffic control