C
Campbell, Kevin (IndSys, GEFanuc, TCP)
Determinism is generally related more to the machine and OS then the
programming language itself. Most functionality in C++ other than dynamic
memory allocation will be deterministic. There are several features in C++
that can produce unexpected overhead (like unexpected copy constructors) but
this will not affect the determinism of your software, it will just slow it
down.
You will get better determinism with native Windows NT than Windows 98.
There are several features in Windows NT you can use to improve your
determinism:
1) Use Multi-media timers to obtain 1ms accuracy for timing and sleep calls
(by default this is 10ms).
2) Use the Real-Time Class for your process to put yourself above the user
mode portions of the OS and avoid the dynamic thread priority balancing of
the lower classes
3) Replace poorly behaved kernel mode device drivers. Because any kernel
mode processing runs above your user mode task, these device drivers will
impact the determinism of your system. The default Hard Disk Driver (ATAPI)
is particularly bad and violates several of Microsoft's own guidelines for
limiting processor stalls. By replacing this with a Bus Mastering DMA
driver, you reduce the interrupt load on the CPU and will have more
deterministic behaviour for your control thread.
4) Use VirtualLock on your code and data pages to eliminate paging to HD. A
Page fault from disk will cause a spike in the order of 30ms
If you have very tight determinism requirements or need timing below 1ms,
your best approach is to use a real-time extension to NT like VenturCom's
RTX.
Kevin
Kevin Campbell
Development Manager
Total Control Products
A Subsidiary of GE Fanuc
(780) 420-2033
[email protected]
programming language itself. Most functionality in C++ other than dynamic
memory allocation will be deterministic. There are several features in C++
that can produce unexpected overhead (like unexpected copy constructors) but
this will not affect the determinism of your software, it will just slow it
down.
You will get better determinism with native Windows NT than Windows 98.
There are several features in Windows NT you can use to improve your
determinism:
1) Use Multi-media timers to obtain 1ms accuracy for timing and sleep calls
(by default this is 10ms).
2) Use the Real-Time Class for your process to put yourself above the user
mode portions of the OS and avoid the dynamic thread priority balancing of
the lower classes
3) Replace poorly behaved kernel mode device drivers. Because any kernel
mode processing runs above your user mode task, these device drivers will
impact the determinism of your system. The default Hard Disk Driver (ATAPI)
is particularly bad and violates several of Microsoft's own guidelines for
limiting processor stalls. By replacing this with a Bus Mastering DMA
driver, you reduce the interrupt load on the CPU and will have more
deterministic behaviour for your control thread.
4) Use VirtualLock on your code and data pages to eliminate paging to HD. A
Page fault from disk will cause a spike in the order of 30ms
If you have very tight determinism requirements or need timing below 1ms,
your best approach is to use a real-time extension to NT like VenturCom's
RTX.
Kevin
Kevin Campbell
Development Manager
Total Control Products
A Subsidiary of GE Fanuc
(780) 420-2033
[email protected]