data sharing between multiple clients of driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all,

I have a question regarding two processes trying to read from same driver.

Context: Suppose the driver maintains a circular buffer and when the
head and tail are same any read request will be blocked. When driver has
data, it asynchronously puts the data in the buffer. In the read system
call then calls wake_up_interruptible() copying the data in user space
buffer.

Question:
If two processes are sleeping on the read() system call for a driver and
when driver has data will both of the processes will get the data or
will there be a race condition? Is it like, the process which wakes up
earlier, reads the data and as a result head and tail become same again.
By the time the next process comes, it again finds there is nothing to
read. If this is the case, then what is the way to share the data? One
way I can think of if having a user space library and all read/writes
should be done only through that library.

Thanks in advance.

--Himanshu


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux