ITPub博客

首页 > 数据库 > Oracle > Oracle latch闩原理示意图

Oracle latch闩原理示意图

Oracle 作者:zhzhypg 时间:2014-11-02 20:40:29 0 删除 编辑

转载地址:http://www.askmaclean.com/archives/oracle-latch闩原理示意图.html
还是搞不懂oracle中latch 闩的原理吗?那么来看看这个图 以及下面这段代码如何?

 

latch

 

Function Get_Latch(latch_name,mode)
{
  If Mode eq ‘immediate’ {
    If Fast_Get(latch_name) {
      return TRUE
    Else {
      return FALSE
    }
  }
  Else {
    If Fast_Get(latch_name)
    Then {
      v$latch.gets++
      return TRUE
    }
    Else {
      v$latch.misses++
      for try = 0 .. large_number
      {
        if Spin_Get(latch_name)
        Then {
          return TRUE
        }
        Else {
          T0 = time
          Sleep(try)
          T1=time
          Register_Event("latch free",T1-T0)
        }
      } -- spin/sleep loop
    }
  }
}

Function Fast_Get(latch_name)
{
  If try_to_get_latch(latch_name)
  Then {
    return TRUE
  }
  Else {
    return FALSE
  }
}

Function Spin_Get(latch_name)
{
  v$latch.spin_get++
  for i = 1 to _spin_count
  {
    If Fast_Get(latch_name)
    Then {
      return TRUE
    }
  }
}

Function Sleep(try)
{
  v$latch.sleeps++
  v$latch.sleep[try]++
  sleeptime =
    decode(try,0,0,1,10,2,20,3,~40,4,~80,...~2000)
  sleep(sleeptime)
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28786649/viewspace-1318032/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-09-01

  • 博文量
    62
  • 访问量
    161372