transformed non-recursive pthread mutex to recursive one