deadlock checking method

this method checks if, for example, p1 holds r1 and wants r2, and
another process pj wants r1 and holds r2 then we have a deadlock.