See lock-recursive-p, lock-owned-by-current-process-p, lock-owner, lock-locked-p and lock-recursively-locked-p.