They look pretty much same to me from programming perspective. From what I read when updating the data, RCU needs to maintain an old copy until all readers are done, which creates large overhead.
Is that the only difference when it comes to implementation ?
Read-Copy-Update (RCU): is not same as reader-writer lock, here are some of the points I can think off:
Separates update and reclamation information, where both readers and writers could avoid locking altogether.
From implementation point of view, RCU is suitable for dynamically allocated data structures, such as linked lists, as the writer does not modify the data in-place, but instead allocates a new element which it initializes with the updated data. The old element is replaced with the new element using an atomic pointer and then new readers will see the newly updated data. Drawback is that old reader will still see the old copy of the data. The old copy must be tracked, and readers must notify the RCU infrastructure that the read is complete, so old data can be reclaimed.
Read-writer-lock: Here a writer prevents another reader or another writer from acquiring the lock, while it has aquired the lock already. Multiple readers can acquire a lock simultaneous, provided no writer has taken the lock.
hope this helps!
In simple terms,
RCU - Concurrency is allowed between a single writer and multiple readers
Reader-Writer locks - Concurrent reads are allowed however not the write operation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With