A system, method and computer readable medium containing programming structions
for an improved latch mechanism for use in a programming environment running concurrent
tasks is disclosed. According to one aspect of the present invention, a latch is
provided to a first task which is requesting access to a resource. After such access,
the first task holds the latch, which is also released from the first task. The
first task holding the latch marks the latch stealable, and if the latch is not
marked stolen by another task, the first task can mark the latch unstealable. In
another embodiment of the present invention, if the first task is provided a latch
marked stealable, the resource associated with the stealable latch will be placed
in a consistent state before the first task accesses the resource.