Database problem concurrency

Implementation of Atomic operations

  1. Dekker's Algorithm
  • needs atomic read and writes to main memory
  • Hard to implement if more than two transactions are involved
  • Use busy waiting
  1. Spin- Lock
  • Need hardware support – should be able lock bus (communication channel between CPU and memory + any other devices) for two memory cycles (one for reading and one for writing). During this time no other devices’ access is allowed to this memory location.
  • use busy waiting
  • Algorithm does not depend on the number of processes
  • Efficient if the lock contentions are low

Deadlock

In deadlock situation, each member of the deadlock processes is waiting for another member to release the resources it wants

  • Solution:
  1. Have enough resources so that no waiting occurs
  2. Linearly order the resources and request of resources should follow this order.
  3. Periodically check the resource dependency graph for cycles
  4. Allow a transaction to wait ofr certain maximum time on a lock and force it to rollback

Probability of Deadlocks

  • Assumption
    1. number of transactions n+1 = n where n is large
    2. each transaction access r locks exclusively
    3. Total number of records in the database = R
    4. On average each transaction is holding r/2 locks approximately
    5. Average number of locks taken by the other n transactions = n*(r/2)



      Capture.PNG
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,854評論 0 10
  • 一開始 心總是溫的 暖暖地看待這個世界 暖暖地望向有你的方向 那時候 陽光 漫不經心的撒下來 時光也凝固 如老照片...
    昔塵閱讀 733評論 2 5
  • 以前我木訥,不會說話,具體表現在說話吞吞吐吐,邏輯不清,最常見的我認為比較尷尬的一點就是沉默,我習慣性的沉默這一點...
    丁火火閱讀 1,008評論 0 0
  • 這課程的意義是不值得定律! 不值得定律,就是如果你覺得一件事不值得做,你就不會把它做好。不值得定律,是“用人”時最...
    是軍兒呀閱讀 324評論 0 0

友情鏈接更多精彩內容