首页 > Linux操作系统 > Linux操作系统 > 翻译 Oracle 8i interal Service (3.1 Latches and Locks)

翻译 Oracle 8i interal Service (3.1 Latches and Locks)

原创 Linux操作系统 作者:wwllzpz 时间:2019-06-15 18:48:07 0 删除 编辑

Chapter 3. Latches

There are numerous data structures in Oracle's System Global Area (SGA) that need to be

accessed concurrently by many different database processes. It is essential that only one

process be able to modify any particular data structure at one time, and that the data

structure cannot be modified while it is being inspected. Oracle makes sure this does not

happen by protecting all SGA data structures with either locks or latches. (See Chapter 6,

for a description of the contents of the SGA and other memory areas.)

第三章 latches

许多不同的数据库进程需要访问SGA,在ORACLESGA中有很多数据结构。在同一时刻,紧紧只让一个进程修改某个特定的数据结构是必要的,当数据结构被检查时,数据结构不能修改。Oracle 使用locks 或者latches来保护所有的SGA数据结构不发生这样事情。

3.1 Latches and Locks

Latches are the more restrictive mechanism, because they do not allow multiple

processes to inspect the protected data structure at the same time—they provide

for exclusive access only.[1] Locks allow for better concurrency, because they may

be held in a shared mode when the data structure is simply being inspected.

[1] This is a simplification. The redo copy latches can be shared, but this is hardware


3.1 latchesLocks


[1] 这里简化了,redo copy latches能被共享,不过要依赖硬件。

Another significant difference between locks and latches is request queuing.

Requests for locks are queued if necessary and serviced in order, whereas latches

do not support request queuing. If a request to get a latch fails because the latch

is busy, the process just continues to retry until it succeeds. So latch requests are

not necessarily serviced in order.


Because a latch can only be held by one process at a time, and because there is no

inherent concept of queuing, the latch data structure itself is very simple—

essentially just a single location in memory representing the state of the latch.

And because the latch data structure is so simple, the functions to get and release

a latch have very little work to do. By contrast, the data structures for locks are

much more sophisticated because of their support for queuing and concurrency.

So the functions to get, convert, and release locks have correspondingly more

work to do.


Of course, it is necessary for Oracle to ensure that only one process at a time can

modify the latch and lock data structures themselves. For latches this is easy.

Because each latch is just a single location in memory, Oracle is able to use the


the underlying hardware's instruction set for its latch get operations. Because

these are simple machine instructions that are guaranteed to be atomic, no other

locking mechanism is needed. This simplicity makes latch gets very efficient.

当然,在同一时刻只允许一个进程修改latchlock它们本身的数据结构是必须的。对latches来说这是简单的。因为每一个latch仅仅有一个内存位置,Oracle能用硬件下指令设置的(instruction set 指令设置, CPU 可以执行的命令TEST,SET,LOAD,CLEAR,COMPARESWAP来对latch进行操作。因为这是简单的保证原子的machine instructions,没有其他锁结构被需要,latch的操作是很高效率的。

Oracle's lock data structures, on the other hand, have several parts, and therefore

cannot be modified atomically. For this reason, Oracle actually protects operations

on locks with latches. The type of latch used varies depending on the type of lock.

For example, the cache buffer locks are indirectly protected by the cache buffers

chains latches, and the row cache enqueue locks are protected by the row cache

objects latch.

Oracle锁的数据结构,有几部分,所以不能被自动修改。由于这种原因,Oraclelatches保护在锁上的操作。这种latch多样化的使用依靠锁的类型。例如,the cache buffer locks间接的被the cache buffers chains latches保护。the row cache enqueue locksthe row cache objects latch保护。

Because latches are efficient, Oracle often uses a latch, rather than a lock and latch

combination, to protect data structures that are expected to be accessed only

briefly and intermittently.

因为latches是很有效的,所以比起锁和latch combinationOracle宁愿用一个latch来保护间歇地,暂时的数据结构。

来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录


  • 博文量
  • 访问量