- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain SHARED, UPDATE and EXCLUSIVE locks with the help of an example
The SHARED, UPDATE and EXCLUSIVE are the types of locks which are used in concurrent application processing. This means that these locks are used when the two or more applications try to access the same row or page. Below is the description for each type of lock.
SHARED LOCK
If any application acquires SHARED LOCK on a page, then it can read that page but cannot update it. Other concurrent applications can acquire the SHARED or UPDATE lock on the same page.
UPDATE LOCK
If any application acquires UPDATE LOCK on a page, then it can read that page but cannot update it. In order to update the page, the application needs to promote the UPDATE LOCK to EXCLUSIVE LOCK. If any application has placed an UPDATE LOCK on a page, then other concurrent processes can only place SHARED locks. UPDATE/EXCLUSIVE locks cannot be placed by the concurrent processes.
EXCLUSIVE LOCK
If any application acquires EXCLUSIVE LOCK on a page, then it can access and update that page. Any other concurrent application cannot place any SHARED or UPDATE lock on the same page.