Method, system, program, and data structure for implementing a locking mechanism for a shared resource
AssigneeSun Microsystems, Inc.
InventorJulian S. Taylor
Life of this patent
Estimating the term…
Abstract
Provided are a method, system, program, and data structure for implementing a locking mechanism to control access to a shared resource. A request is received to access the shared resource. A determination is made of whether a first file has a first name. The first file is renamed to a second name if the first file has the first name. A second file is updated to indicate the received request in a queue of requests to the shared resource if the first file is renamed to the second name. An ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request. The first file is renamed to the first name after the second file is updated.
Claims63
A method for implementing a locking mechanism to control access to a shared resource, comprising:
- receiving a request to access the shared resource;
- determining whether a first file has a first name;
- renaming the first file to a second name if the first file has the first name;
- updating a second file to indicate the received request in a queue of requests to the shared resource if the first file is renamed to the second name, wherein an ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request;
- and
- renaming the first file to the first name after the second file is updated.
A system for implementing a locking mechanism to control access to a shared resource, comprising:
- a file system;
- a processor in communication with the first computer readable medium and file system;
- code implemented in the computer readable medium executed by the processor to cause the processor to perform:
- (i) receiving a request to access the shared resource;
- (ii) determining whether a first file in the file system has a first name;
- (iii) renaming the first file to a second name if the first file has the first name;
- (iv) updating a second file in the file system to indicate the received request in a queue of requests to the shared resource if the first file is renamed to the second name, wherein an ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request;
- and
- (v) renaming the first file to the first name after the second file is updated.
A system for implementing a locking mechanism to control access to a shared resource, comprising:
- a file system implemented including a first file and a second file;
- means for receiving a request to access the shared resource;
- means for determining whether the first file has a first name;
- means for renaming the first file to a second name if the first file has the first name;
- means for updating the requests to the shared resource if the first file is renamed to the second name, wherein an ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request;
- and
- means renaming the first file to the first name after the second file is updated.
An article of manufacture including code for implementing a locking mechanism to control access to a shared resource, wherein the code causes operations to be performed comprising:
- receiving a request to access the shared resource;
- determining whether a first file has a first name;
- renaming the first file to a second name if the first file has the first name;
- updating a second file to indicate the received request in a queue of requests to the shared resource if the first file is renamed to the second name, wherein an ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request;
- and
- renaming the first file to the first name after the second file is updated.
The article of manufacture of claim 56, wherein the request to access is for non-exclusive access to the shared resource and wherein the lease data structure indicates a number of requests allowed simultaneous access to the shared resource, wherein determining whether one considered request in the queue is permitted access to the shared resource further comprises:
- determining whether a number of current readers is less than the allowed readers;
- determining whether less than the number of current readers precedes the considered request in the queue;
- updating the lease data structure to identify the considered request and set a new lease time for the considered request to have non-exclusive access to the shared resource if the number of current readers is less than the allowed readers and less than the number of current readers precedes the considered request in the queue;
- and
- incrementing the number of current readers after updating the lease data structure to indicate the considered request.
A computer readable medium including data structures for implementing a locking mechanism to control access to a shared resource, comprising:
- a first file having one of a first name or a second name, wherein in response to receiving a request to access the shared resource, the first file is renamed to the second name if the first file has the first name;
- and
- a second file indicating a queue of requests to the shared resource, wherein an ordering of the requests in the queue is used to determine whether access to the shared resource is granted to the request, and wherein the second file is updated to indicate the received request in the queue when the first file is renamed to the second name, wherein the first file is renamed to the first name after the second file is updated.
Dependencies are inferred from the claim text.