Hi All,
For clarification i am using 8 Instances.
Thanks for “Tim” posts and i think i am going on right direction and getting some good behaviour too.
But i noticed some starnge result that i want to share with Tim and others.
As you mentioned about reset event in your last post, i changed CreateEvent function with auto-reset and non-signaled state. Ok, so that was my first modification.
Now as you mentioned that and according to below suggestion:
while( thread_still_running )
{
dwEvent = WFMO( INSTANCES, hEvents, FALSE, INFINITE );
if( dwEvent < INSTANCES )
{
SLS_W32_WriteFile( hDevice, bWBuf1, iNoOfByteToWrite, &junk,
&ov[dwEvent] );
}
}
i got “dwEvent” like 2,3,0, etc. Now if i got 3 means what? It means that scheduler completes 3,4,5,6,7 Instances or it complets 0,1,2,3. From the MSDN docs i found and i understood that it completed 3,4,5,6,7 Instances. So from your suggestion it only post that INSTANCE whcih i got return value from WFMO. So does this have any performace down?
Now i changed some logic and apply some tests. I used below code for Test1
TEST1:
//Created INSTANCE with auto reset and non signaled state. and loop =10000, iNoOfByteToWrite = 4096Bytes
for(int ii=0;ii{
SLS_W32_WriteFile(hDevice,bWBuf1,iNoOfByteToWrite,&junk, &ov[ii]);
}
int j=INSTANCES;
while(j<(loop))
{
dwEvent = WaitForMultipleObjects(INSTANCES, // number of objects in array
hEvents, // array of objects
FALSE, // wait for any
INFINITE); // indefinite wait
if(dwEvent {
for(int t=0;t<=dwEvent;++t)
{
SLS_W32_WriteFile( hDevice, bWBuf1, iNoOfByteToWrite, &junk,&ov[t] );
j++;
}
}
}
But using this test i got two different results. In one case at the device side i am not able to get all transaction. Even thogh application fires loop 10000 times.so i have to ran once again the application and need to repeat above procedure for 4000-5000 times and then i got completed 10000 transaction at device side. But for all trasaction my time is 0.5 to 0.6 ms . that very surprised me .Actaully i want this result but i think there is some data loss in between.
Now in second result i got all trasaction as completed. but i also got spikes of 8-9 ms after certain transactions.And overall spikes count in 10000 trasanction is 25-26.
TEST2 :
//Created INSTANCE with auto reset and non signaled state. and loop =10000, iNoOfByteToWrite = 4096
for(int ii=0;ii{
SLS_W32_WriteFile(hDevice,bWBuf1,iNoOfByteToWrite,&junk, &ov[ii]);
}
int j=INSTANCES;
while(j<(loop))
{
dwEvent = WaitForMultipleObjects(INSTANCES, // number of objects in array
hEvents, // array of objects
FALSE, // wait for any
INFINITE); // indefinite wait
if(dwEvent {
for(int t=dwEvent;t<=INSTANCES;++t)
{
SLS_W32_WriteFile( hDevice, bWBuf1, iNoOfByteToWrite, &junk,&ov[t] );
j++;
}
}
}
But got same result as in TEST1.
i also used another method. Please see below my code:
I created all event in manual reset and non-signaled mode and loop = 10000 and iNoOfByteToWrite= 4096 Byts
int j=INSTANCES;
while(j<(loop))
{
dwEvent = WaitForMultipleObjects(INSTANCES, // number of objects in array
hEvents, // array of objects
FALSE, // wait for any
INFINITE); // indefinite wait
if( dwEvent>=0 && dwEvent < INSTANCES )
{
for(int t=0;t {
int value = WaitForSingleObject(hEvents[t],0);
if(value == WAIT_OBJECT_0)
{
ResetEvent(ov[i].hEvent);
SLS_W32_WriteFile( hDevice, bWBuf1, iNoOfByteToWrite, &junk,&ov[t] );
j++;
}
}
}
}
But in this i got same results as in TEST1 and TEST2.
So i am confuse about that WFMO returns what? I think that i am vey nearer to result but doing something wrong which makes me failure.
Please suggest me.
Tejas
SLS inc.
www.slscorp.com