Read/write lock with reduced reader lock sampling overhead in absence of writer lock acquisition
First Claim
Patent Images
1. A method for synchronizing access to shared data, comprising:
- when reading said shared data is performed by a data reader;
said data reader testing a writer flag that indicates whether a separate data writer is attempting to access said shared data;
said data reader accessing said shared data using a fast read mechanism if said writer flag is not set, said fast read mechanism including said data reader performing an indicating action prior to reading said shared data that indicates to data writers desiring to access said shared data that said data reader has initiated accessing said shared data using said fast read mechanism; and
said data reader accessing said shared data using a slow read mechanism if said writer flag is set, said slow read mechanism including said data reader waiting for a data writer to complete its access to said shared data; and
when writing said shared data is performed by a data writer;
said data writer setting said writer flag;
following said writer flag setting, said data writer waiting for expiration of a grace period in which all executing instances of said data reader have an opportunity to either see said writer flag and initiate said slow read mechanism or complete said indicating action indicating that said data reader has initiated said fast read mechanism;
following said grace period expiration, said data writer waiting until there are no data readers accessing said shared data using said fast read mechanism;
following said waiting until there are no data readers, said data writer acquiring a lock on said shared data, said lock being different from said writer flag; and
said data writer accessing said shared data.
1 Assignment
0 Petitions
Accused Products
Abstract
An improved reader-writer locking for synchronizing access to shared data. When writing the shared data, a writer flag is set and a lock is acquired on the shared data. The shared data may be accessed following the expiration of a grace period and a determination that there are no data readers accessing the shared data. When reading the shared data, the writer flag is tested that indicates whether a data writer is attempting to access the shared data. If the writer flag is not set, the shared data is accessed using a relatively fast read mechanism. If the writer flag is set, the shared data is accessed using a relatively slow read mechanism.
57 Citations
20 Claims
-
1. A method for synchronizing access to shared data, comprising:
-
when reading said shared data is performed by a data reader; said data reader testing a writer flag that indicates whether a separate data writer is attempting to access said shared data; said data reader accessing said shared data using a fast read mechanism if said writer flag is not set, said fast read mechanism including said data reader performing an indicating action prior to reading said shared data that indicates to data writers desiring to access said shared data that said data reader has initiated accessing said shared data using said fast read mechanism; and said data reader accessing said shared data using a slow read mechanism if said writer flag is set, said slow read mechanism including said data reader waiting for a data writer to complete its access to said shared data; and when writing said shared data is performed by a data writer; said data writer setting said writer flag; following said writer flag setting, said data writer waiting for expiration of a grace period in which all executing instances of said data reader have an opportunity to either see said writer flag and initiate said slow read mechanism or complete said indicating action indicating that said data reader has initiated said fast read mechanism; following said grace period expiration, said data writer waiting until there are no data readers accessing said shared data using said fast read mechanism; following said waiting until there are no data readers, said data writer acquiring a lock on said shared data, said lock being different from said writer flag; and said data writer accessing said shared data. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A data processing system having one or more processors, a memory and a communication pathway between the one or more processors and the memory, said system being adapted to synchronize access to shared data, and comprising:
-
a writer flag settable by a data writer that indicates whether said data writer is attempting to access said shared data; fast path read logic executed by a data reader and adapted to coordinate fast reader access to said shared data on behalf of said data reader when said writer flag is not set by said data writer, said fast reader access including said data reader performing an indicating action prior to reading said shared data that indicates to data writers desiring to access said shared data that said data reader has initiated accessing said shared data using said fast read access; slow path read logic executed by said data reader and adapted to coordinate slow reader access to said shared data on behalf of said data reader when said writer flag is set, said slow reader access including said data reader waiting for a data writer to complete its access to said shared data; first write logic executed by said data writer and adapted to set said writer flag; grace period processing logic executed by said data writer and adapted to implement a grace period following said writer flag being set by said data writer; second write logic executed by said data writer after said first write logic and adapted to wait for expiration of said grace period in which all executing instances of said data reader have an opportunity to either see said writer flag and initiate said slow path read logic or complete said indicating action of said fast path read logic; third write logic executed by said data writer after said second write logic and adapted to wait until there are no data readers accessing said shared data using said fast path read logic; and fourth write logic executed by said data writer after said third write logic and adapted to acquire a lock on said shared data on behalf of said data writer, said lock being different from said writer flag. - View Dependent Claims (9, 10, 11, 12, 13)
-
-
14. A computer program product for synchronizing access to shared data, comprising:
-
one or more non-transitory machine-readable media; program instructions provided by said one or more media for programming a data processing platform to operate as by; when reading said shared data is performed by a data reader; said data reader testing a writer flag that indicates whether a separate data writer is attempting to access said shared data; said data reader accessing said shared data using a fast read mechanism if said writer flag is not set, said fast read mechanism including said data reader performing an indicating action prior to reading said shared data that indicates to data writers desiring to access said shared data that said data reader has initiated accessing said shared data using said fast read mechanism; and said data reader accessing said shared data using a slow read mechanism if said writer flag is set, said slow read mechanism including said data reader waiting for a data writer to complete its access to said shared data; and when writing said shared data is performed by a data writer; said data writer setting said writer flag; following said writer flag setting, said data writer waiting for expiration of a grace period in which all executing instances of said data reader have an opportunity to either see said writer flag and initiate said slow read mechanism or complete said indicating action of indicating that said data reader has initiated said fast read mechanism; upon expiration of said grace period, said data writer waiting until there are no data readers accessing said shared data using said fast read mechanism; following said waiting until there are no data readers, said data writer acquiring a lock on said shared data, said lock being different from said writer flag; and said data writer accessing said shared data. - View Dependent Claims (15, 16, 17, 18, 19)
-
-
20. A computer program product for synchronizing access to shared data, comprising:
-
one or more non-transitory machine-readable media; program instructions provided by said one or more media for programming a data processing platform to operate as by; a data writer setting a writer flag; following said writer flag setting, said data writer waiting for expiration of a grace period in which all executing instances of a data reader of said shared data have an opportunity to either see said writer flag and initiate a slow read mechanism or perform a fast read mechanism indicating action that indicates to a data writer desiring to access said shared data that said data reader has initiated accessing said shared data using said fast read mechanism; following said grace period expiration, said data writer waiting until there are no data readers accessing said shared data; following said waiting until there are no data readers, said data writer acquiring a lock on said shared data, said lock being different from said writer flag; and said data writer accessing said shared data.
-
Specification