Stable algorithms for input queued switches