SlideShare a Scribd company logo
Locks In Distributed
Systems
Mridul K Mishra(170303201015)
What is it?
 In computer science, a lock is a synchronization mechanism for enforcing
limits on access to a resource in an environment where there are many
threads of execution. A lock is designed to enforce a mutual exclusion
concurrency control policy.
 In Distributed Systems(referred to as DS from now on), lock is a mechanism
that allows only one of the innumerable nodes(or process) to access and
modify a resource or data that is being shared commonly to prevent execution
of same task twice and also maintain data integrity.
 In the common database of a bank, at a given instance of time only one node(at
bank branch or user himself using personal banking) should be able to carry out a
transaction on a given bank account ( Data Integrity).
Why is it needed?
 Any DS always uses a database, and concurrent tasks are always performed by different
nodes, so analogous to the relational database,
 R-W anomaly
 W-R anomaly
 W-W anomaly
may occur. This ensures integrity and consistency of data. This lock is for Correctness.
 In addition to this, the system has to ensure that only one process is fired for
execution of a single task, e.g. in an inventory, upon shortage of a needed
resource, order should be placed only once. This increases the efficiency and
throughput of the system. And similar to single computer OS, problems like
Deadlock can occur, which have to be prevented. This lock is for Efficiency.
 The basic idea behind locks is to decrease the cost of carrying out operations in a
DS by ensuring that among several nodes trying to do a task only one does it(at a
given instance of time).
 Although locks are valid in DS for both above stated scenarios, the locking
mechanism should be chosen wisely according to the need. E.g. In many cases
applying the lock to prevent repetition of task might be costlier than task itself.
How Is It Implemented?
 Compared to conventional OS and relational database, the locking mechanism in a DS is quite
complicated as the network itself or the nodes can independently fail at any time.
 There are various algorithms deployed for this in different DS, E.g. Redlock, Paxos. The lock
managers are generally referred to as Distributed Lock Managers(DLM)
 The DLM uses a generalized concept of a resource, which is some entity to which shared
access must be controlled. This can relate to a file, a record, an area of shared memory, or
anything else that the application designer chooses. A hierarchy of resources may be defined,
so that a number of levels of locking can be implemented. For instance, a hypothetical
database might define a resource hierarchy as follows:
 Database
 Table
 Record
 Field
 A process can then acquire locks on the database as a whole, and then on particular parts of
the database. A lock must be obtained on a parent resource before a subordinate resource
can be locked.
 Various types of Locks that are granted by DLM in order of their hierarchy are:
 Null(NL):Process wants to lock resource, but does not stop others from getting lock
on it.
 Concurrent Read(CR):Multiple processes can read a resource but not update it.
 Concurrent Write(CW):Multiple processes can read and update a resource but no
exclusive access provide.
 Protected Read(PR):A process( or multiple) reads a resource but prevents others
from updating it
 Protected Write(PW):Indicates that a process will read and update a resource.
Prevents others from updating it. CW lock holders can read it.
 Exclusive(EX):This is the traditional exclusive lock which allows read and update
access to the resource, and prevents others from having any access to it
 A process can upgrade its lock as per need and permission of DLM.
 The following table explains the relation between above stated locks:
 A lock value block is associated with each resource. This can be read by any
process that has obtained a lock on the resource (other than a null lock) and
can be updated by a process that has obtained a protected update or
exclusive lock on it. And based on above tables locks can be updated.
Issues
Although DLMs provide for data integrity some issues that might arise are:
 Lost Update: say we have an application in which a client needs to update a
file in shared storage. A client first acquires the lock, then reads the file,
makes some changes, writes the modified file back, and finally releases the
lock and in meantime the lock/lease expires. Another client acquires the lock
The lock prevents two clients from performing this read-modify-write cycle
concurrently, which would result in lost updates. Explained by diagram.
 Using Timestamps/tokens can solve this issue.
 Deadlock: When one or more processes have obtained locks on resources, it
is possible to produce a situation where each is preventing another from
obtaining a lock, and none of them can proceed. This is known as a deadlock.
 A simple example is when Process 1 has obtained an exclusive lock on Resource A,
and Process 2 has obtained an exclusive lock on Resource B. If Process 1 then tries
to lock Resource B, it will have to wait for Process 2 to release it. But if Process 2
then tries to lock Resource A, both processes will wait forever for each other.
Advantages:
 Ensures the Correctness of
transactions.
 System becomes more robust i.e.
prevents system failures
Illustrations:
 Chubby- Designed by Google for
loosely coupled DS
 Apache ZooKeeper- An open source
manager designed by Yahoo.
 Redis - an open source, BSD
licensed, advanced key-value
cache and store
References
 Wikipedia
 https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-
locking.html
Thank You

More Related Content

What's hot

Deadlock management
Deadlock managementDeadlock management
Deadlock management
Ahmed kasim
 
Distributed transaction
Distributed transactionDistributed transaction
Distributed transaction
MohitKothari26
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency ControlAli Usman
 
Database , 12 Reliability
Database , 12 ReliabilityDatabase , 12 Reliability
Database , 12 ReliabilityAli Usman
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
Kathirvel Ayyaswamy
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
Dilum Bandara
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replicationAbDul ThaYyal
 
Naming in Distributed Systems
Naming in Distributed SystemsNaming in Distributed Systems
Naming in Distributed Systems
Nandakumar P
 
Resource management
Resource managementResource management
Resource management
Dr Sandeep Kumar Poonia
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
SHATHAN
 
Coda file system
Coda file systemCoda file system
Coda file system
Sneh Pahilwani
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Security in distributed systems
Security in distributed systems Security in distributed systems
Security in distributed systems
Haitham Ahmed
 
Distributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query ProcessingDistributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query Processing
Gyanmanjari Institute Of Technology
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
Sunita Sahu
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithmsDistributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
MNM Jain Engineering College
 
File replication
File replicationFile replication
File replication
Klawal13
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
SHIKHA GAUTAM
 

What's hot (20)

Deadlock management
Deadlock managementDeadlock management
Deadlock management
 
Distributed transaction
Distributed transactionDistributed transaction
Distributed transaction
 
Database ,11 Concurrency Control
Database ,11 Concurrency ControlDatabase ,11 Concurrency Control
Database ,11 Concurrency Control
 
Database , 12 Reliability
Database , 12 ReliabilityDatabase , 12 Reliability
Database , 12 Reliability
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Transactions and Concurrency Control
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replication
 
Naming in Distributed Systems
Naming in Distributed SystemsNaming in Distributed Systems
Naming in Distributed Systems
 
Resource management
Resource managementResource management
Resource management
 
Synchronization in distributed systems
Synchronization in distributed systems Synchronization in distributed systems
Synchronization in distributed systems
 
Coda file system
Coda file systemCoda file system
Coda file system
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Security in distributed systems
Security in distributed systems Security in distributed systems
Security in distributed systems
 
Distributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query ProcessingDistributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query Processing
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Clock synchronization in distributed system
Clock synchronization in distributed systemClock synchronization in distributed system
Clock synchronization in distributed system
 
4. system models
4. system models4. system models
4. system models
 
Distributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithmsDistributed Mutual exclusion algorithms
Distributed Mutual exclusion algorithms
 
File replication
File replicationFile replication
File replication
 
Agreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared MemoryAgreement Protocols, distributed File Systems, Distributed Shared Memory
Agreement Protocols, distributed File Systems, Distributed Shared Memory
 

Similar to Locks In Disributed Systems

Locking and concurrency
Locking and concurrencyLocking and concurrency
Locking and concurrency
RumeysaDinsoy
 
a hybrid cloud approach for secure authorized
a hybrid cloud approach for secure authorizeda hybrid cloud approach for secure authorized
a hybrid cloud approach for secure authorized
logicsystemsprojects
 
Ieeepro techno solutions 2014 ieee dotnet project - a hybrid cloud approach...
Ieeepro techno solutions   2014 ieee dotnet project - a hybrid cloud approach...Ieeepro techno solutions   2014 ieee dotnet project - a hybrid cloud approach...
Ieeepro techno solutions 2014 ieee dotnet project - a hybrid cloud approach...
ASAITHAMBIRAJAA
 
Ieeepro techno solutions 2014 ieee java project - a hybrid cloud approach f...
Ieeepro techno solutions   2014 ieee java project - a hybrid cloud approach f...Ieeepro techno solutions   2014 ieee java project - a hybrid cloud approach f...
Ieeepro techno solutions 2014 ieee java project - a hybrid cloud approach f...
hemanthbbc
 
What is active-active
What is active-activeWhat is active-active
What is active-active
Saif Ahmad
 
Chap 07 Locking.pptx
Chap 07  Locking.pptxChap 07  Locking.pptx
Chap 07 Locking.pptx
SunenaGhulamani
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikSaeed Siddik
 
Computer Security
Computer SecurityComputer Security
Computer Security
Hajer alriyami
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed Databases
Meghaj Mallick
 
Abhishek Kumar - CloudStack Locking Service
Abhishek Kumar - CloudStack Locking ServiceAbhishek Kumar - CloudStack Locking Service
Abhishek Kumar - CloudStack Locking Service
ShapeBlue
 
Doc A hybrid cloud approach for secure authorized deduplication
 Doc A hybrid cloud approach for secure authorized deduplication Doc A hybrid cloud approach for secure authorized deduplication
Doc A hybrid cloud approach for secure authorized deduplicationShakas Technologie
 
Vani dbms
Vani dbmsVani dbms
Vani dbms
SangeethaSasi1
 
Process coordination
Process coordinationProcess coordination
Process coordination
Sweta Kumari Barnwal
 
Rdbms
RdbmsRdbms
Security and Integrity violations, Authorisation and views, Integrity Constant
Security and Integrity violations, Authorisation and views, Integrity ConstantSecurity and Integrity violations, Authorisation and views, Integrity Constant
Security and Integrity violations, Authorisation and views, Integrity Constant
Prakash Kumar
 
Mit201– operating system
Mit201– operating systemMit201– operating system
Mit201– operating system
smumbahelp
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
Jacob Zvirikuzhe
 
Database Management Systems (DBMS)
Database Management Systems (DBMS)Database Management Systems (DBMS)
Database Management Systems (DBMS)Dimara Hakim
 
Distributed database
Distributed databaseDistributed database
Distributed database
sanjay joshi
 

Similar to Locks In Disributed Systems (20)

Locking and concurrency
Locking and concurrencyLocking and concurrency
Locking and concurrency
 
a hybrid cloud approach for secure authorized
a hybrid cloud approach for secure authorizeda hybrid cloud approach for secure authorized
a hybrid cloud approach for secure authorized
 
Ieeepro techno solutions 2014 ieee dotnet project - a hybrid cloud approach...
Ieeepro techno solutions   2014 ieee dotnet project - a hybrid cloud approach...Ieeepro techno solutions   2014 ieee dotnet project - a hybrid cloud approach...
Ieeepro techno solutions 2014 ieee dotnet project - a hybrid cloud approach...
 
Ieeepro techno solutions 2014 ieee java project - a hybrid cloud approach f...
Ieeepro techno solutions   2014 ieee java project - a hybrid cloud approach f...Ieeepro techno solutions   2014 ieee java project - a hybrid cloud approach f...
Ieeepro techno solutions 2014 ieee java project - a hybrid cloud approach f...
 
What is active-active
What is active-activeWhat is active-active
What is active-active
 
Locking in SQL Server
Locking in SQL ServerLocking in SQL Server
Locking in SQL Server
 
Chap 07 Locking.pptx
Chap 07  Locking.pptxChap 07  Locking.pptx
Chap 07 Locking.pptx
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddik
 
Computer Security
Computer SecurityComputer Security
Computer Security
 
Overview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed DatabasesOverview of Concurrency Control & Recovery in Distributed Databases
Overview of Concurrency Control & Recovery in Distributed Databases
 
Abhishek Kumar - CloudStack Locking Service
Abhishek Kumar - CloudStack Locking ServiceAbhishek Kumar - CloudStack Locking Service
Abhishek Kumar - CloudStack Locking Service
 
Doc A hybrid cloud approach for secure authorized deduplication
 Doc A hybrid cloud approach for secure authorized deduplication Doc A hybrid cloud approach for secure authorized deduplication
Doc A hybrid cloud approach for secure authorized deduplication
 
Vani dbms
Vani dbmsVani dbms
Vani dbms
 
Process coordination
Process coordinationProcess coordination
Process coordination
 
Rdbms
RdbmsRdbms
Rdbms
 
Security and Integrity violations, Authorisation and views, Integrity Constant
Security and Integrity violations, Authorisation and views, Integrity ConstantSecurity and Integrity violations, Authorisation and views, Integrity Constant
Security and Integrity violations, Authorisation and views, Integrity Constant
 
Mit201– operating system
Mit201– operating systemMit201– operating system
Mit201– operating system
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Database Management Systems (DBMS)
Database Management Systems (DBMS)Database Management Systems (DBMS)
Database Management Systems (DBMS)
 
Distributed database
Distributed databaseDistributed database
Distributed database
 

Recently uploaded

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Locks In Disributed Systems

  • 1. Locks In Distributed Systems Mridul K Mishra(170303201015)
  • 2. What is it?  In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. A lock is designed to enforce a mutual exclusion concurrency control policy.  In Distributed Systems(referred to as DS from now on), lock is a mechanism that allows only one of the innumerable nodes(or process) to access and modify a resource or data that is being shared commonly to prevent execution of same task twice and also maintain data integrity.  In the common database of a bank, at a given instance of time only one node(at bank branch or user himself using personal banking) should be able to carry out a transaction on a given bank account ( Data Integrity).
  • 3. Why is it needed?  Any DS always uses a database, and concurrent tasks are always performed by different nodes, so analogous to the relational database,  R-W anomaly  W-R anomaly  W-W anomaly may occur. This ensures integrity and consistency of data. This lock is for Correctness.  In addition to this, the system has to ensure that only one process is fired for execution of a single task, e.g. in an inventory, upon shortage of a needed resource, order should be placed only once. This increases the efficiency and throughput of the system. And similar to single computer OS, problems like Deadlock can occur, which have to be prevented. This lock is for Efficiency.
  • 4.  The basic idea behind locks is to decrease the cost of carrying out operations in a DS by ensuring that among several nodes trying to do a task only one does it(at a given instance of time).  Although locks are valid in DS for both above stated scenarios, the locking mechanism should be chosen wisely according to the need. E.g. In many cases applying the lock to prevent repetition of task might be costlier than task itself.
  • 5. How Is It Implemented?  Compared to conventional OS and relational database, the locking mechanism in a DS is quite complicated as the network itself or the nodes can independently fail at any time.  There are various algorithms deployed for this in different DS, E.g. Redlock, Paxos. The lock managers are generally referred to as Distributed Lock Managers(DLM)  The DLM uses a generalized concept of a resource, which is some entity to which shared access must be controlled. This can relate to a file, a record, an area of shared memory, or anything else that the application designer chooses. A hierarchy of resources may be defined, so that a number of levels of locking can be implemented. For instance, a hypothetical database might define a resource hierarchy as follows:  Database  Table  Record  Field  A process can then acquire locks on the database as a whole, and then on particular parts of the database. A lock must be obtained on a parent resource before a subordinate resource can be locked.
  • 6.  Various types of Locks that are granted by DLM in order of their hierarchy are:  Null(NL):Process wants to lock resource, but does not stop others from getting lock on it.  Concurrent Read(CR):Multiple processes can read a resource but not update it.  Concurrent Write(CW):Multiple processes can read and update a resource but no exclusive access provide.  Protected Read(PR):A process( or multiple) reads a resource but prevents others from updating it  Protected Write(PW):Indicates that a process will read and update a resource. Prevents others from updating it. CW lock holders can read it.  Exclusive(EX):This is the traditional exclusive lock which allows read and update access to the resource, and prevents others from having any access to it
  • 7.  A process can upgrade its lock as per need and permission of DLM.  The following table explains the relation between above stated locks:
  • 8.  A lock value block is associated with each resource. This can be read by any process that has obtained a lock on the resource (other than a null lock) and can be updated by a process that has obtained a protected update or exclusive lock on it. And based on above tables locks can be updated.
  • 9. Issues Although DLMs provide for data integrity some issues that might arise are:  Lost Update: say we have an application in which a client needs to update a file in shared storage. A client first acquires the lock, then reads the file, makes some changes, writes the modified file back, and finally releases the lock and in meantime the lock/lease expires. Another client acquires the lock The lock prevents two clients from performing this read-modify-write cycle concurrently, which would result in lost updates. Explained by diagram.
  • 10.  Using Timestamps/tokens can solve this issue.  Deadlock: When one or more processes have obtained locks on resources, it is possible to produce a situation where each is preventing another from obtaining a lock, and none of them can proceed. This is known as a deadlock.  A simple example is when Process 1 has obtained an exclusive lock on Resource A, and Process 2 has obtained an exclusive lock on Resource B. If Process 1 then tries to lock Resource B, it will have to wait for Process 2 to release it. But if Process 2 then tries to lock Resource A, both processes will wait forever for each other.
  • 11. Advantages:  Ensures the Correctness of transactions.  System becomes more robust i.e. prevents system failures Illustrations:  Chubby- Designed by Google for loosely coupled DS  Apache ZooKeeper- An open source manager designed by Yahoo.  Redis - an open source, BSD licensed, advanced key-value cache and store