Patent ID: 7353515
Filing Date: 2008-04-01
Classification: G06F

Abstract:
1. A computer-implemented method for dynamic allocation and management of semaphores for accessing shared resources, the method comprising: maintaining a resource lock table data structure indicating for each of a plurality of resources an allocated semaphore of a plurality of semaphores; maintaining a semaphore allocation table data structure indicating the currently used semaphores for said resources of a plurality of semaphores; and in response to a received resource request for a particular resource from a first task, locating an indication of the particular resource in a particular entry in the resource lock table structure, the particular entry identifying that the particular resource is currently associated with a first semaphore; and in response: getting a second semaphore from a pool of free semaphores, updating a semaphore entry in the semaphore allocation table to reflect that the particular resource is associated with the second semaphore in addition to the first semaphore, and signaling to the first task the availability of the particular resource; wherein the second semaphore is associated with a timeout value; and wherein the method further comprises: in response to the end of a timeout period corresponding to the timeout value: returning the second semaphore to the pool of free semaphores, updating the semaphore entry in the semaphore allocation table to reflect that the particular resource is no longer associated with the second semaphore, and signaling to the first task that the particular resource is not available; and wherein the received resource request is for read access to the particular resource; and the method further comprises: updating the particular entry in the resource lock table structure to reflect an additional read lock associated with the particular resource; and in response to the end of a timeout period corresponding to the timeout value, updating the particular entry in the resource lock table structure to reflect one less read lock associated with the particular resource.