Information Technology Reference
In-Depth Information
The unlock .T;x;m;d/ (Algorithm 6.2 )isusedto release the lock .T;x;m;d/.
The hash-structured lock table is searched for the lock name x, and, given the pointer
l to the lock, the call release-lock .T; l/ (Algorithm 6.3 ) is used to release the lock
and to wake up any process threads that are waiting for the release.
In order to facilitate the release of locks after completing a partial rollback to a
savepoint, the setting of savepoint P in the call set-savepoint .T; P / (Algorithm 4.3 )
is logged with a log record,
n Wh T;SŒP;l;n 0 i ;
(6.1)
that also contains the pointer, l , to the last lock acquired by T before setting the
savepoint (Algorithm 6.4 ).
The call complete-rollback-to-savepoint .T; P / (Algorithm 4.6 ) that is executed
as the last step in the call rollback-to-savepoint .T; P / (Algorithm 4.4 )nowtakes
as a third argument the pointer value l logged when setting savepoint P . The call,
given as Algorithm 6.5 , releases all locks acquired by T after lock l .
Algorithm 6.1 Procedure lock .T;x;m;d/
M fm 0 j alock.T;x;m 0 ;d/exists in the lock tableg
if m 6 m 0 for all m 0 2 M then
while requested lock not granted do
if the lock table does not contain any lock .T 0 ;x;m 0 ;d 0 / where T 0 6D T and m 0 is
incompatible with m then
m 00 sup.fmg[M/
insert .T;x;m 00 ;d/into the lock table
put .T;x;m 00 ;d/into the two-way chain pointed to from L AST -L OCK .T /
L AST -L OCK .T / pointer to .T;x;m 00 ;d/
else
wait for the conflicting locks to be released
end if
end while
end if
Algorithm 6.2 Procedure unlock .T;x;m;d/
l pointer to the lock .T;x;m;d/in the lock table
release-lock .T; l/
Algorithm 6.3 Procedure release-lock .T; l/
detach the lock l from the two-way chain ending at L AST -L OCK .T /
if L AST -L OCK .T / D l then
L AST -L OCK .T / pointer to the last record in the chain
end if
delete the lock l from the lock table
wake up the first thread in the queue waiting for the release of lock l (if any)
 
Search WWH ::




Custom Search