[Info-vax] counting-lock ?

Pierre pierre.bru at gmail.com
Sun Oct 25 15:11:58 EDT 2009


On Oct 22, 11:07 pm, JON... at ecr6.ohio-state.edu (David Jones) wrote:
> In message <91916ca0-728c-407a-8a35-eda053501... at l31g2000vbp.googlegroups.com>,

> Off the top of my head.
>
> Have 2 DLM resource: A, B.
>
> Acquire:
>    1. Get EX mode lock on A.
>    2. Get CR mode lock on B.
>    3. Use $GETLKI to get GRANTCOUNT on B.
>    4. If grantcount <= n then
>          dequeue lock A
>          return success.
>       endif
>    5. convert lock B to PW mode with blocking
>       AST.
>    6. Wait for blocking AST or a timeout.
>    7. if timeout then
>           dequeue B
>           dequeue A
>           return error.
>       endif
>    9. convert lock B to CR mode.
>   10. dequeue lock A
>   11. return success.
>
> Release:
>    1. Convert lock B to CW mode. (signals waiter if queued.).
>    2. Dequeue lock B

this looks interesting but if the process holding lock B dies before
converting it to CW, the process waiting for B may wrongly exit on the
timeout (or wait forever if no timeout is used). the same may happen
if (unfortunately) a process holding a lock on B exits between
counting and the conversion of lock on B to PW.



More information about the Info-vax mailing list