Saturday, May 11, 2024

Local Lock

There is one local lock in each address space. Local lock is obtained with interrupt enabled. When the function holding local lock is interrupted, dispatcher will not dispatch new TCB in the address space. When the interrupt is handled, the function holding the lock is re-dispatched to let it finishes its work quickly, even though there may be other work that has higher priority is ready. 

If a TCB is already running on another cpu while a local lock is obtained by the current task, dispatcher will let that TCB continue to run until it releases control or interrupted.  But then that TCB will remain suspended until the local lock is released by the current task. 

When a normal task is interrupted, system saved its registers in the IHSA (interrupt handler save area). But if the task is holding a local lock when it is interrupted, the register is saved in a different location. 

Local lock can be requested either as spin or suspend lock. 

No comments: