簡體   English   中英

為什么必須使用巨人鎖才能使用任何非睡鎖

[英]Why Giant Lock must be taken before any non-sleepable locks

我試圖理解第三點的原因 -最重要的是必須從下面的鏈接獲得條件:

https://www.freebsd.org/cgi/man.cgi?locking(9)

巨人

Giant是一種特殊的互斥鎖,用於保護尚未擁有自己鎖的數據結構。 由於它提供類似於舊的spl(9)接口的語義,因此Giant具有特殊的特征:

 1.   It is recursive.

 2.   Drivers can request that Giant be locked around them by not marking
  themselves MPSAFE.  Note that infrastructure to do this is slowly
  going away as non-MPSAFE drivers either became properly locked or
  disappear.

 3.   Giant must be locked before other non-sleepable locks.

 4.   Giant is dropped during unbounded sleeps and reacquired after
  wakeup.

 5.   There are places in the kernel that drop Giant and pick it back up
  again.  Sleep locks will do this before sleeping.  Parts of the net-
  work or VM code may do this as well.  This means that you cannot
  count on Giant keeping other code from running if your code sleeps,
  even if you want it to.

約翰·鮑德溫(John Baldwin)在他的BSDcon 論文中對此規則提供了更詳細的解釋:

收購Giant時,不得持有任何鎖。 這樣可以確保無論是否持有巨人,都可以始終安全地獲取其他鎖。 反過來,這允許擁有自己的鎖的子系統在不持有Giant的情況下直接調用,並由仍需要Giant的其他子系統調用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM