Locks and Latches (鎖與閂)
I would have included pins and mutexes in the title, but that would have made it too long and lose the alliteration. Oracle uses all four mechanisms
to ensure that resources don't get damaged by conflicting requirements for access and modification. The mechanisms may slow down the rate at
which you are allowed to work, to ensure that you can work safely, although, as we shall see in Chapter 7, some of the mechanisms can save you
time when you keep repeating the same piece of works.
我其實想將硝(pins)與互斥(mutex)放到我的標題裡,但這麼做會造成這篇文章的標題太長且不押韻。Oracle使用了4種機制來確保當資料遇到同時被存取或修改時不會受到損壞。這些方法也會降低發生的機率,來確保資料的安全性。 當你重複做一些動作時,這些機制也會節省掉您的時間。
There are two significant differences between locks and latches. Locks and pins adopt a polite, queue-like strategy with a first-come,first-serverd
apporach, while latches and mutexes adopt a pushy strategy where everone tries to grab the latch simultaneously. Secondly, locks, pins, and
some mutexes tend to be held for a significant amount of time, while latches should be held only ver briefly. The difference are, in many ways,
a sied effect of the difference in usage - locks tend to be used to protect objects, while latches tend to be used to protect shared memory,
so the latch activeity tends to be highly concurrent and very quick.
鎖與閂存在著明顯的差別,鎖與硝是一種禮貌性的行為,採取一種先到先服務的方法。反之,閂與互斥則採用一種咄咄逼人的方式,每個人都會試圖掌握閂。第二,鎖與硝以及
一些互斥會持有較長的時間,而閂,持有的時間是非常的短的。
上述的不同,也造成使用的目的不同,鎖是用來保護物件,閂則是用來保護共享記憶體。因此,閂的行為往往是非常快速且並行的。
As you can see from these comments, mutexes(which started to appear in Oracle Database 10g most significantly as a replacement for pins in the
library cache) fall somewhere between locks and latches:session fight over mutexes the way they fight over latches, but sessions can hold mutexes
for long periods just as they can hold locks(and pins) for long time.
你可以看到这些评论,介于两者之间的互斥锁和锁存在互斥锁:他们战斗过的道路战斗的会议,但会议可以持有互斥体长时间就像他们可以持有锁的时间长(销)。
First Things, First...
Before we can talk about what latces are and how they work, though, you need some idea of how Oracle uses arrays, pointers, linked lists,
and hash table when tracking information in memory, because those are the types of structure that need the most protection when they are share
by mulitple users.
在我们谈论的锁存器是什么以及它们如何工作,虽然,你需要如何使用数组,链表指针,一些想法,和哈希表时,跟踪信息的记忆,因为这些都是类型的结构,最需要保护时,他们被多个用户共享。
留言列表