An algorithm for resource deadlock detection in distributed systems