We describe a simple and efficient algorithm to detect deadlocks in distributed systems. In our model, processes request N resources from a pool of size M. This is a generalization of the well-known AND-OR request model. The algorithm is incrementally derived and proven correct. Its communication, computational, and space requirements are lower than those of the best previously known algorithms for the simpler AND-OR model.