ISOUSB + FILE_FLAG_OVERLAPPED. Does it work?



Hi!

Do I have to modify the ISOUSB (WinXP DDK) sample to make it work properly
with overlapped I/O?
I got it work well with blocking I/O, but not with overlapped I/O. I was
somehow instable.
Before I get into heavy driver debugging, I'd like to ask some experienced
people if it should work this way:


I've changed a few things in my well working stable code to avoid blocking
of its write() function.
I've changed my CreateFile call to:

CreateFile(devnames[dev_id],
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
/*0*/ FILE_FLAG_OVERLAPPED, // (adding FILE_FLAG_NO_BUFFERING
didn't help me out)
NULL);

//Global variables:
OVERLAPPED m_osWrite[1024];
int overlap_index = 0;
...
...
//the write function looks something like this:
void write(...............)
{
ZeroMemory(&(m_osWrite[overlap_index]), sizeof(m_osWrite[overlap_index]));
m_osWrite[overlap_index].hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

WriteFile(filehandles[dev_id],
writebuffs[dev_id],
buffsize*4,
/*&nBytesWrite*/ NULL, // leaving &nBytesWrite here didn't change
anything
/*NULL*/ &(m_osWrite[overlap_index]))

overlap_index++;
if (overlap_index>=1024)
overlap_index = 0;
}

The reason for the global overlap_index and the plenty of global OVERLAPPED
structs is that the DDK doc states out that the OVERLAPPED stuct must not
run out of scope and it has to be valid until the I/O has been completed.

Now, if I call write() like this:

int a;
for (a=0;a<100;a++)
write(.............);

...it should work, I think (overlap_index didn't spin around, so every
WriteFile got its own overlapped struct).
The first 100 OVERLAPPED structs will be used and they will remain always
valid, since they are simple gobal variables.
I don't need a completion routine, so I'm not using WriteFileEx.

Should the ISOUSB example work with this code, or do I have to modify
something?
(it works well without overlapped I/O)

Thanks,
greg1x


.



Relevant Pages

  • Re: How Can I DeviceIoControl in less than 10 milliseconds?
    ... gives me no benefit over blocking I/O. ... You are using it in a sequential, blocking manner. ... Overlapped I/O is best ... used when you can start an operation running and then move on to other ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How Can I DeviceIoControl in less than 10 milliseconds?
    ... gives me no benefit over blocking I/O. ... You are using it in a sequential, blocking manner. ... Overlapped I/O is best ... used when you can start an operation running and then move on to other ...
    (microsoft.public.win32.programmer.kernel)