Method and apparatus for managing a lock for an object
First Claim
1. In a shared memory model system, a method whereby, in a state wherein a plurality of threads exist, a bit that represents a lock type and an identifier for a thread that has acquired a lock in accordance with a first lock type, or an identifier of a second lock type, are stored in a storage area that corresponds to an object and a lock on an object is thus managed, said method comprising:
- determining, if a second thread attempts to acquire a lock on a specific object that is held by a first thread, whether a bit that represents said lock type on said specific object represents said first lock type;
setting a contention bit if said bit represents said first lock type;
determining, before said first thread unlocks said specific object, whether said bit that represents said lock type represents said first lock type;
storing in said storage area a special identifier that differs from the identifiers for said plurality of threads;
issuing a synchronization command for said memory system;
storing in said storage area data indicating the absence of a thread that holds said lock on said specific object;
determining whether said contention bit has been set if said bit that represents said lock type represents said first lock type; and
terminating an unlocking process if said contention bit has not been set without any other process being performed.
1 Assignment
0 Petitions
Accused Products
Abstract
An innovative compound lock method is provided that does not reduce the processing speed attained along a frequent path. When no thread is locking an object (1), a value of 0 is stored both in a lock field and in a contention bit. Then, when a specific thread locks an object (light lock), the identifier of the thread is stored in the lock field (2). If any other thread attempts to acquire a lock before the thread designated by the thread identifier unlocks the object, SPECIAL is stored in the lock field (5), and the process is returned to (1). If a different thread attempts to acquire a lock before the designated thread unlocks the object, this causes a contention to occur in the light lock mode, and a contention bit is set to record it (3). Thereafter, when the lock mode is shifted to the fat lock mode, the contention bit is cleared (4), and if possible, the process is shifted from (4) to (1).
-
Citations
18 Claims
-
1. In a shared memory model system, a method whereby, in a state wherein a plurality of threads exist, a bit that represents a lock type and an identifier for a thread that has acquired a lock in accordance with a first lock type, or an identifier of a second lock type, are stored in a storage area that corresponds to an object and a lock on an object is thus managed, said method comprising:
-
determining, if a second thread attempts to acquire a lock on a specific object that is held by a first thread, whether a bit that represents said lock type on said specific object represents said first lock type;
setting a contention bit if said bit represents said first lock type;
determining, before said first thread unlocks said specific object, whether said bit that represents said lock type represents said first lock type;
storing in said storage area a special identifier that differs from the identifiers for said plurality of threads;
issuing a synchronization command for said memory system;
storing in said storage area data indicating the absence of a thread that holds said lock on said specific object;
determining whether said contention bit has been set if said bit that represents said lock type represents said first lock type; and
terminating an unlocking process if said contention bit has not been set without any other process being performed. - View Dependent Claims (2, 3, 4)
-
-
5. In a shared memory model system, an apparatus where, in a state wherein a plurality of threads exist, a bit that represents a lock type and an identifier for a thread that has acquired a lock in accordance with a first lock type, or an identifier of a second lock type, are stored in a storage area that corresponds to an object and a lock on an object is thus managed, said apparatus comprising:
-
means for determining, if a second thread attempts to acquire a lock on a specific object that is held by a first thread, whether a bit that represents said lock type on said specific object represents said first lock type;
means for setting a contention bit if said bit represents said first lock type;
means for determining, before said first thread unlocks said specific object, whether said bit that represents said lock type represents said first lock type;
means for storing in said storage area a special identifier that differs from the identifiers for said plurality of threads;
means for issuing a synchronization command for said storage area;
means for storing in said storage area data indicating the absence of a thread that maintains said lock on said specific object;
means for determining whether said contention bit has been set if said bit that represents said lock type represents said first lock type; and
means for terminating an unlocking process if said contention bit has not been set without any other process being performed. - View Dependent Claims (6, 7, 8)
-
-
9. In a shared memory model system, a method whereby, in a state wherein a plurality of threads exist, a bit that represents a lock is stored in a storage area that corresponds to an object, and a queue of a thread that accesses said object is stored to manage a lock on an object, said method comprising:
-
determining, when a second thread attempts to acquire a lock on a specific object that a first thread has locked, whether a bit that is used to represent said lock on said object represents the locked state;
changing data for the number of queues of threads that access said specific object and storing the updated data when said bit represents said locked state;
storing said second thread in a queue, and shifting said second thread to a control state, for a mechanism that performs a waiting operation for accessing said specific object and a recovery operation by transmitting a notification;
storing said bit that represents said locked state in said storage area before said first thread unlocks said object;
determining whether a thread that is stored in a queue is present;
shifting said first thread to a notification state, wherein said transmission of a notification to said thread that is waiting is initiated, when a thread that is stored in a queue is present; and
permitting said first thread to exit said notification state. - View Dependent Claims (10)
-
-
11. In a shared memory model system, a method whereby, in a state wherein a plurality of threads exist, a bit that represents a lock is stored in a storage area that corresponds to an object, and a queue of threads that access said object is stored to manage a lock on an object, said method comprising:
-
determining, when a second thread attempts to acquire a lock on a specific object that a first thread has locked, whether a bit that represents said lock on said object represents the locked state;
changing, when said bit represents said locked state, data for the number of queues of threads that can access said specific object and storing the updated data, and thereafter issuing a synchronization command for said storage area;
storing said second thread in a queue, and shifting said second thread to a control state for a mechanism that performs a waiting operation, for accessing said specific object, and a recovery operation by transmitting a notification;
storing in said storage area, before said first thread unlocks said object, said bit that represents said locked state and an identifier that is not related to the representation of said locked state or an unlocked state;
issuing a synchronization command for said storage area;
storing, in said storage area, data that does not represent said lock on said specific object;
determining whether a thread that is stored in a queue is present;
shifting, when a thread that is stored in a queue is present, said first thread to a notification state wherein said transmission is initiated for issuing a notification to said thread that is waiting; and
permitting said first thread to exit said notification state. - View Dependent Claims (12, 13)
-
-
14. In a shared memory model system, an apparatus where, in a state wherein a plurality of threads exist, a bit that represents a lock is stored in a storage area that corresponds to an object, and a queue of a thread that accesses said object is stored to manage a lock on an object, said apparatus comprising:
-
means for determining, when a second thread attempts to acquire a lock on a specific object that a first thread has locked, whether a bit that is used to represent said lock on said object represents the locked state;
means for changing data for the number of queues of threads that access said specific object and storing the updated data when said bit represents said locked state;
means for storing said second thread in a queue, and shifting said second thread to a control state, for a mechanism that performs a waiting operation for accessing said specific object and a recovery operation by transmitting a notification;
means for storing said bit that represents said locked state in said storage area before said first thread unlocks said object;
means for determining whether a thread that is stored in a queue is present;
means for shifting said first thread to a notification state, wherein said transmission of a notification to said thread that is waiting is initiated, when a thread that is stored in a queue is present; and
means for permitting said first thread to exit said notification state. - View Dependent Claims (15)
-
-
16. In a shared memory model system, an apparatus where, in a state wherein a plurality of threads exist, a bit that represents a lock is stored in a storage area that corresponds to an object, and a queue of threads that access said object is stored to manage a lock on an object, said apparatus comprising:
-
means for determining, when a second thread attempts to acquire a lock on a specific object that a first thread has locked, whether a bit that represents said lock on said object represents the locked state;
means for changing, when said bit represents said locked state, data for the number of queues of threads that can access said specific object and storing the updated data, and thereafter issuing a synchronization command for said storage area;
means for storing said second thread in a queue, and shifting said second thread to a control state for a mechanism that performs a waiting operation, for accessing said specific object, and a recovery operation by transmitting a notification;
means for storing in said storage area, before said first thread unlocks said object, said bit that represents said locked state and an identifier that is not related to the representation of said locked state or an unlocked state;
means for issuing a synchronization command for said storage area;
means for storing, in said storage area, data that does not represent said lock on said specific object;
means for determining whether a thread that is stored in a queue is present;
means for shifting, when a thread that is stored in a queue is present, said first thread to a notification state wherein said transmission is initiated for issuing a notification to said thread that is waiting; and
means for permitting said first thread to exit said notification state. - View Dependent Claims (17, 18)
-
Specification