Consider a Linux device driver that implements the functions open (), read (), write (), close (), unlocked_ioctl (), and possibly mmap ().
Now imagine that several (or the same) processes simultaneously open the same device (/ dev / device).
Are these file operations guaranteed in any way atomic wrt to each other or should each of open (), read (), write (), close () accept a mutex so that one of their pairs does not preempt them, being in the middle of the change, for example , buffer data (via the same index)?
It is not necessary that the kernel guarantees their atomicity with respect to each other, and if each operation finds and leaves the buffer / hardware in a consistent state.
Please redirect me to some link (if you know).
Thanks.
edit: it is in one of the comments, but the best link I found is here:
http://www.makelinux.net/ldd3/chp-6-sect-6
It also shows strategies to alleviate the problem, either by restricting one user, or by making copies, or by making the user wait, etc.
source share