I have multiple threads that use the same HANDLE for a device object,
created by:
CreateFile(_T(…), GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
Now i noticed if a DeviceIoControl() of a thread blocks and waits for an event, other threads are blocked whenever they use DeviceIoControl, until the first thread finishes and returns to userspace.
I’m talking about different ioctls on the same device.
One ioctl blocks, the other ioctl just changes a flag(no syncronization mechanism over there, nothing… no blocking)
Marcel nailed it. The ioctl code and the driver architecture do not matter in this case. Without FILE_FLAG_OVERLAPPED in the CreateFile call, regardless of how the driver is written, the operating system will only allow one outstanding I/O operation at a time on that file handle. It doesn’t matter how many threads you have. All other calls will block until the first completes.
By design. You opened a synchronous/serialized handle. If you want multiple simultaneous io, open it with file flag overlapped.
Bent from my phone
From: xxxxx@lists.osr.com on behalf of xxxxx@gmail.com Sent: Thursday, March 15, 2018 6:27:49 AM To: Windows System Software Devs Interest List Subject: [ntdev] Can a DeviceIoControl block?
I have multiple threads that use the same HANDLE for a device object, created by: CreateFile(_T(…), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Now i noticed if a DeviceIoControl() of a thread blocks and waits for an event, other threads are blocked whenever they use DeviceIoControl, until the first thread finishes and returns to userspace.
________________________________ From: xxxxx@lists.osr.com on behalf of xxxxx@gmail.com Sent: Thursday, March 15, 2018 9:46:19 AM To: Windows System Software Devs Interest List Subject: RE:[ntdev] Can a DeviceIoControl block?
I’m talking about different ioctls on the same device. One ioctl blocks, the other ioctl just changes a flag(no syncronization mechanism over there, nothing… no blocking)