Add atomic register access for all backends #1370
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
Local Backend
First patch introduces thread-safe register read/write operations for the local backend using
direct_reg_accessvia debugfs. It adds two new backend ops:reg_read()reg_write()These functions use file locking (
flock) to ensure atomic access and prevent race conditions when multiple threads interact with the same register interface.The fallback logic in
iio_device_reg_read()andiio_device_reg_write()is preserved for backends that do not implement these atomic operations.This improves reliability for multi-threaded applications using libiio with the local backend.
Network, USB and Serial Backends
Second patch implement atomic register operations which ensures that a register read or a register write cannot be interrupted by other clients of IIOD.
Advantages:
On client-server compatibility:
v1.0 clients can connect to v1.0+ servers (atomic ops used)
v1.0 clients connecting to v0.x servers fall back to attribute method
Closes #1351.
PR Type
PR Checklist