Hi All,
Is it possible to issue a ReadFile and a WriteFile on the same device handle but from different threads simultaneously?
The device handle was returned by CreateFile function which reads like-
devHandle = CreateFile("\\.\USB_DEV, // device to open
GENERIC_READ | GENERIC_WRITE, // open for reading & writing
FILE_SHARE_READ | FILE_SHARE_WRITE, // // share for reading & writing
NULL, // default security
OPEN_EXISTING, // open // existing devices only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attributes template
One of my threads issued a ReadFile (synchronous i/o) on devHandle and is pending in the device driver for data to become available at (say) READ_BUFFER. One of the other thread then tries to write data (WriteFile again synchronous i/o) on devHandle to a different buffer (say) WRITE_BUFFER in the device driver. This sequence is hanging the system to hang.
So, i am wondering if a simulaneous ReadFile and a WriteFile to the same devHandle is a NO-NO condition.
Inside the device driver, i am making sure that such read and write i/o requests are serialized.
Any pointers are highly welcome.
Thanks in advance.