06-22-2006 08:26 PM
06-22-2006 08:33 PM
Whoops! I have done the wrong thing and posted this prior to finishing - sorry.
I think the question that remains, can i get that read/write data sequence steps to the card be 'locked out' for a while from NT doing other things? Is the cvintdrv.sys that does the inp()/outp() still being given enought priority? How does the cvintdrv.sys actually work here?
06-23-2006 12:21 PM
Murray -
If you think that NT is "off doing other things" you can boost the priority of the thread doing the i/o.
WinNT has a "realtime" priority class, it's a bit drastic, pretty much nothing else will run if you set your thread to realtime priority. No mouse movement, no key clicks, etc. etc. You'd likely have to be clever about it, only boosting to realtime priority on a temporary basis. A separate realtime thread to do the low level i/o might help simplify the design.
You can use the Win32 SDK to boost your thread's priority.
Menchar
06-23-2006 09:06 PM
06-26-2006 12:47 PM
Murray -
Sorry, didn't read your first message carefully. Yes, you're getting your process into the realtime priority class, but you need to further set thread priority to
THREAD_PRIORITY_TIME_CRITICAL
or THREAD_PRIORITY_HIGHEST
to get the thread's base priority up to where you're certain you're going to be running at the highest priority.
NT may not support THREAD_PRIORITY_TIME_CRITICAL , that may have been added for Win2K or WinXP, not certain.
A priority class is a set of priorites as it turns out - you have to add the priority class to the thread priority to come up with the true thread priority (highest value is 31).
The Win32 SDK included with CVI FSD describes this - also see Beveridge & Weiner "Multithreading Applications in Win32".
Menchar
06-27-2006 07:30 AM
Other information including some of the source code is here in this thread http://forums.ni.com/ni/board/message?board.id=180&message.id=23842. To answer a question from that thread,
>>So does win95 have less overheads and do the loops faster?
Yes. The short version is that 95 is not a pre-emptive system, your program had virtually complete access and control over the hardware when it is executing. NT on the other hand allows your application to run for a bit (a time slice) then pulls control back to take care of other tasks.
Do you know which timeout value you are getting? There are two places that return SD811_IBF_TIMEOUT, which would require changing one of them to get more information if that is the returned error.
I do think your on the right track as far as looking at this as a timing problem. Making the changes suggested by menchar is probably a good place to start.
06-28-2006 08:11 PM
After researching further the priority classes and threads, I implemented this code, but with no observable difference. So now I am really at a loss.
hprocess = GetCurrentProcess();
oldPC = GetPriorityClass(hprocess);
SetPriorityClass(hprocess, REALTIME_PRIORITY_CLASS);
hThread = GetCurrentThread();
oldTP = GetThreadPriority(hThread);
SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
error = SD811_GetData (&data);
SetThreadPriority(GetCurrentThread(), oldTP);
SetPriorityClass(GetCurrentProcess(), oldPC);
06-29-2006 06:38 AM
Are the calls to SetPriorityClass() and SetThreadPriority() succeeding?
If they are, I suspect that Windows may be de-scheduling your process occasionally when the low level driver is called, which in your case is a bit of a pity. It's not easy to find out what goes on in Windows when device drivers are called from applications.