Locks can be marked as recursive or not recursive, and they can be made sharing or exclusive. There are APIs for querying whether a lock can be, or actually is, locked recursively.
There are some guarantees about the lock / unlock functions.