The concept of nested lock is mainly extended according to a situation in programming. What's the situation? We can explain it in detail. Suppose that when you are dealing with a public function, you add a lock because the public data is involved. But it's a little sad. The public function itself also adds a lock, which is the same as the lock you add. So unless you use semaphores, your program won't get the lock for life.
There are many reasons for this. One important aspect is that different people are responsible for each module of the software. So essentially, we can't be sure what kind of lock someone else is using. You have no right not to let someone else use a lock. So, in this case, it's up to you. Nested locks are a good solution.
(1) data structure of nested lock
(2) apply for nested lock
(3) release the lock
(1) nested lock is not so much a new lock type as a statistical lock
(2) nested lock is as convenient as ordinary lock
(3) nested locks also have disadvantages, which brings troubles to our lock detection