關於互斥:
When a mutex is shared between processes, there is always a chance that the process can terminate (perhaps involuntarily) while holding the mutex lock. There is no way to have the system automatically release held locks upon process termination. We will see that read-write locks and Posix semaphores share this property. The only type of synchronization locks that the kernel always cleans up automatically upon process termination is fcntl record locks(Chapter 9). When using System V semaphores, the application chooses whether a semaphore lock is automatically cleaned up or not by the kernel upon process termination (the SEM_UNDO feature that we talk about in Section 11.3).
書中還提到:
即使一個進程終止時系統自動釋放某個鎖,那也可能解決不了問題。
該鎖保護某個臨界區很可能是為了在執行該臨界區代碼期間更新某個資料。
如果該進程在執行該臨界區的中途終止,該資料處於什麼狀態呢?該資料處於不一致狀態的可能性很大。
如果核心僅僅在進程終止時自動解鎖的話,通常於事無補。
需要小心使用。
關於Posix有名號誌:
“關閉一個號誌並沒有將它從系統中刪除。這就是說,
Posix有名號誌至少是隨核心持續的:即使當前沒有進程開啟著某個號誌,它的值仍然保持。”