Starting to implement deadlock algorythm