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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,164评论 0 10
  • 一开始 心总是温的 暖暖地看待这个世界 暖暖地望向有你的方向 那时候 阳光 漫不经心的撒下来 时光也凝固 如老照片...
    昔尘阅读 3,907评论 2 5
  • 以前我木讷,不会说话,具体表现在说话吞吞吐吐,逻辑不清,最常见的我认为比较尴尬的一点就是沉默,我习惯性的沉默这一点...
    丁火火阅读 4,388评论 0 0
  • 这课程的意义是不值得定律! 不值得定律,就是如果你觉得一件事不值得做,你就不会把它做好。不值得定律,是“用人”时最...
    是军儿呀阅读 2,047评论 0 0