What is the diffrence between lock and latch?

Questions by ramanjidba   answers by ramanjidba

Showing Answers 1 - 9 of 9 Answers

locks protect data during transactions, another process, latching, controls access to physical pages.

Latches are very lightweight, short-term synchronization objects protecting actions that do not need to be locked for the life of a transaction.

  Was this answer useful?  Yes

Nishanth

  • Mar 14th, 2016
 

The difference between the two is that Locks are queueing mechanisms while Latches are not.
If two processes are spinning and waiting on a latch (access to a shared memory resource) and the resource protected by the latch becomes free (is released/unpinned by the holder), then whichever of the two waiters "wakes up" first from its spin gets the Latch. This is serialisation in the sense of "only one person at a time".
In an Lock -- eg shared locks on a table -- the access is granted on "first come first served". This is serialisation in the sense "access is via a Queue". That is why we can build a "lock tree" but not a "latch tree".

  Was this answer useful?  Yes

Sri

  • Aug 16th, 2017
 

Locks are to maintain read consistency and will be applied on tables and the same kind on instance memory structures is called latch.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions