Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1300733
  • 博文数量: 127
  • 博客积分: 2286
  • 博客等级: 大尉
  • 技术积分: 1943
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-10 10:37
文章分类

全部博文(127)

文章存档

2018年(1)

2015年(2)

2014年(1)

2013年(30)

2012年(88)

2011年(5)

分类: Oracle

2013-04-17 13:02:50

Oracle数据库中latch和mutex都要用到原子操作,到底怎么实现的,理解起来比较抽象,
Oracle教材只说了跟系统相关有实例就好理解了。
 在x86的机器上,都是通过嵌入汇编代码的来实现的,汇编代码又是通过lock前缀的汇编语言
来锁系统总线来防止数据被并发修改的,具体是这样的:

先反汇编
objdump -d $ORACLE_HOME/bin/oracle > oracle.asm

再用下面的awk脚本来提取函数

点击(此处)折叠或打开

  1. BEGIN {
  2. fun_name99 = "x"
  3. isPrint = "N"
  4. }
  5. {
  6. if ( match($0,/.+<(.+)>:$/, anames))
  7. {
  8. fun_name99 = anames[1]
  9. }
  10. if ( match($0, /(\W+lock\W+)(.*)/, anames))
  11. {
  12. if (isPrint == "N" && FNAME != "x" )
  13. {
  14. print fun_name99
  15. isPrint = "Y"
  16. }
  17. if ( fun_name99 != "x" )
  18. {
  19. print anames[1] anames[2]
  20. }
  21. }
  22. if ( match($0,/^\W*$/))
  23. {
  24. fun_name99 = "x"
  25. isPrint = "N"
  26. }
  27. }
得到不到200个的函数

点击(此处)折叠或打开

  1. dbkefFreeGate
  2. dbkefGetGate
  3. __intel_new_memcpy
  4. jslvepost_exec_post
  5. jslvepre_exec_pre
  6. jslvss_session_start
  7. jslvsst_session_stop
  8. kcbchg1_main
  9. kcb_commit_main
  10. kcbgcur
  11. kcbgtcr
  12. kcbgtcrf
  13. kcbm_trace
  14. kcb_post_apply
  15. kcb_pre_apply
  16. kcbr_allocate_buf
  17. kcbr_apply_change
  18. kcbr_dump_lost_write
  19. kcbrls
  20. kcbr_make_free
  21. kcbr_mapply_change
  22. kcbr_media_apply
  23. kcbrra
  24. kcbupg
  25. kcbzar
  26. kcbzjr
  27. kclaffinity
  28. kclanticheck
  29. kclblkdone
  30. kclbr
  31. kclcclaim
  32. kclcfusion
  33. kclcls
  34. kclcsr
  35. kcldgbfs
  36. kclebs
  37. kclfchk
  38. kclfplz
  39. kclfprm
  40. kclfwrite2
  41. kclgclk
  42. kclgclks
  43. kclgrantlk
  44. kclgrlk
  45. kclgrnew
  46. kclgrrs
  47. kclgvlk
  48. kcllcsod
  49. kcl_le_flush
  50. kclliter
  51. kcllkopb
  52. kcllkopesc
  53. kclllook
  54. kclnfndnewm
  55. kclnfnds
  56. kclnfndx
  57. kclollnumiter
  58. kclplz
  59. kclprm
  60. kcl_raisepr_deadproc
  61. kclrbypass
  62. kclrecbst
  63. kclrls
  64. kclswc
  65. kclulbf
  66. kclverify
  67. kclwcrs
  68. kclzcli
  69. kcrm_post_ctrl_reply
  70. kcsadj2
  71. kcsadj3
  72. kcslaj2
  73. kcsnew2
  74. kcsnew2_latched
  75. kcsnew3
  76. kcsset3
  77. kecpsBgSendReferencesHelper
  78. kecpsCommitPostCall
  79. kecpsDBCommitPost
  80. kecpsGetProcess
  81. kecpsGetProcessFromSso
  82. kecpsReleaseProcess
  83. kecpsRemoveProcess
  84. kecpsSendReferencesRemote
  85. kecpsThreadFailureRefCountsCalls
  86. kecpsThreadFailureRefCountsDBCommits
  87. kecrInitFlagsIDs
  88. kecuCas
  89. keshs_generate_unique_ub8
  90. kghnospc
  91. kgkpccl
  92. kgkpgcremovefrl
  93. kgkpgpickfirst
  94. kgkpioaddtowl
  95. kgkpiopicknext
  96. kgkpioremovefrl
  97. kgkprraddtorl
  98. kgkprrpicknext
  99. kgkprtcaddtorl
  100. kgkprtcpicknext
  101. kgnfsxid
  102. kgsk_bumpup_ioc
  103. kgskbwt
  104. kgskchk
  105. kgskckques
  106. kgskdecr
  107. kgskdeq
  108. kgskewtint
  109. kgskgincr
  110. kgskincr
  111. kgskmodruncnt
  112. kgskmvthrs
  113. kgskpincr
  114. kgskrecalc
  115. kgsk_release_ioc
  116. kgsk_reset_vt_stats
  117. kgskrunnext
  118. kgskrunnextint
  119. kgskslc
  120. kgsksysresume
  121. kgsksysstop
  122. kgskthrexit
  123. kgskthrrun
  124. kgxDecrementExamine
  125. kgxExclusive
  126. kgxExclusiveNowait
  127. kgxLongExclusive
  128. kgxModifyRefCount
  129. kgxRelease
  130. kgxShared
  131. kgxSharedExamine
  132. kgxSharedNowait
  133. kgxSharedNowaitExamine
  134. kjbmpocr
  135. kjbmprclaim
  136. kkjcjchk
  137. kkjspub
  138. kmccvc
  139. kmcpdp
  140. kmmpis
  141. kmmpism
  142. ksdxexeother
  143. ksl_adjust_latch
  144. kslcllt
  145. kslclt_cln
  146. kslconx
  147. kslfre
  148. kslges
  149. kslgess
  150. ksl_get_child_latches
  151. kslgetl
  152. ksl_get_shared_latch
  153. kslgpl
  154. kslrwfl
  155. kslskgs
  156. ksl_skgslgts
  157. ksl_tst_kgslo
  158. kslwlmod
  159. ksm_dump_sga_heap
  160. ksmpgd_get_exclusive
  161. ksmss_alloc
  162. ksnpost
  163. ksudlp
  164. ksuitm
  165. ksu_logout_storm_manager
  166. ksuprlat_test
  167. ktcAllocXcb
  168. ktcdso
  169. ktclcu
  170. ktcsod
  171. kxfpClearQueuingLoad
  172. kxfpdasg
  173. kxfpgsg
  174. kxfpMarkRACLoadStatInv
  175. kxfpMarkRACLoadStatVal
  176. kxfpuqpq
  177. pesldl110_CAS
  178. __PGOSF726_ksllini
  179. qerblCRop
  180. qerblEof
  181. qesblClearBfm
  182. qesblFoldTo
  183. qesblMerge
  184. qesblReduce
  185. qesblsSet
  186. qesblSyncThruQC
  187. qesrcBlf_HsvClr
  188. qesrcBlf_HsvSet
  189. qmr_kdsololr_hi

可以看出原子操作主要要下面3类操作:
1 Compare and Set(cas),绝大大部分都是样的
kslgetl:
lock cmpxchg %rsi,(%r12)

2 减一个数
kslfre:
lock sub %rcx,(%r15)
lock sub %rax,(%r15)

3 加一个数
kecpsGetBlockers:
lock add %rax,0x48(%r15)
阅读(5478) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~