Architecture for a read/write thread lock
Abstract
An architecture for a read/write thread lock is provided for use in a computing environment where several sets of computer instructions, or “threads,” can execute concurrently. The disclosed thread lock allows concurrently-executing threads to share access to a resource, such as a data object. The thread lock allows a plurality of threads to read from a resource at the same time, while providing a thread exclusive access to the resource when that thread is writing to the resource. The thread lock uses critical sections to suspend execution of other threads when one thread needs exclusive access to the resource. Additionally, a technique is provided whereby the invention can be deployed as constructors and destructors in a programming language, such as C++, where constructors and destructors are available. When the invention is deployed in such a manner, it is possible for a programmer to issue an instruction to lock a resource, without having to issue a corresponding unlock instruction.
Claims
exact text as granted — not AI-modified1 - 45 . (canceled)
46 . A method of managing a resource shared among concurrently-executing threads in a multi-threaded computer program running under an operating system that supports multi-threaded computer programs, said method comprising the acts of:
maintaining a record for maintaining information as to whether any of the threads is accessing the resource at a given point in time, the record comprising a read counter and a write counter; issuing a request for a lock by creating a local class instance by a constructor for the local class instance; receiving, from a first thread, a request for a lock, the request indicating whether the request is for a read lock or for a write lock; if the request is for a read lock, granting said request and permitting the thread to proceed unless another of the threads is writing the resource; and if said request is for a write lock, granting the request and permitting the thread to proceed unless another of the threads is reading or writing the resource; wherein issuing a request by the constructor comprising:
obtaining a lock on the resource
recording the lock in the record;
incrementing the read counter when any of the threads reads from the resource; and
incrementing the write counter when any of the threads writes to the resource.
47 . The method of claim 46 , wherein the method further comprising:
issuing a request to release the lock by destroying the local class instance by destructor, issuing the request comprising: releasing the lock; recording the release of the lock in the record; and decrementing the read counter and the write counter.
48 . The method of claim 47 , wherein said class instance is a class instance in the C++ programming language.
49 . The method of claim 47 , further comprising determining whether other threads are reading or writing the resource, wherein the determinations of whether other threads are reading or writing from the resource are made by claiming one or more critical sections.
50 . The method of claim 49 , wherein the critical sections are implemented by way of a critical section facility of the operating system.
51 . The method of claim 50 , wherein the value of the read counter is the number of read locks outstanding on the resource.
52 . The method of claim 51 , wherein the act of claiming at least one of the critical sections is conditioned upon the value of the read counter.
53 . The method of claim 46 , wherein said resource comprises a data object located within the address space of the computer program.
54 . A computer-readable medium having computer-executable instructions to perform a method of managing a resource shared among concurrently-executing threads in a multi-threaded computer program running under an operating system that supports multi-threaded computer programs, said method comprising the acts of:
maintaining a record for maintaining information as to whether any of the threads is accessing the resource at a given point in time, the record comprising a read counter and a write counter; issuing a request for a lock by creating a local class instance by a constructor for the local class instance; receiving, from a first thread, a request for a lock, the request indicating whether the request is for a read lock or for a write lock; if the request is for a read lock, granting said request and permitting the thread to proceed unless another of the threads is writing the resource; and if said request is for a write lock, granting the request and permitting the thread to proceed unless another of the threads is reading or writing the resource; wherein issuing a request by the constructor comprising:
obtaining a lock on the resource
recording the lock in the record;
incrementing the read counter when any of the threads reads from the resource; and
incrementing the write counter when any of the threads writes to the resource.
55 . The computer-readable medium of claim 54 , wherein the method further comprising:
issuing a request to release the lock by destroying the local class instance by destructor, issuing the request comprising: releasing the lock; recording the release of the lock in the record; and decrementing the read counter and the write counter.
56 . The computer-readable medium of claim 55 , wherein said class instance is a class instance in the C++ programming language.
57 . The computer-readable medium of claim 55 , further comprising determining whether other threads are reading or writing the resource, wherein the determinations of whether other threads are reading or writing from the resource are made by claiming one or more critical sections.
58 . The computer-readable medium of claim 57 , wherein the critical sections are implemented by way of a critical section facility of the operating system.
59 . The computer-readable medium of claim 58 , wherein the value of the read counter is the number of read locks outstanding on the resource.
60 . The computer-readable medium of claim 59 , wherein the act of claiming at least one of the critical sections is conditioned upon the value of the read counter.
61 . The computer-readable medium of claim 55 , wherein said resource comprises a data object located within the address space of the computer program.Join the waitlist — get patent alerts
Track US2006242644A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.