[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 810
  • Last Modified:

Windows application resolution (task switching)

I need to send some signals to a device via USB port. The signal needs to switch from 1 to 0 every 45ms or so (the logic of the signal is a bit more complex, but we can simplify it and say that we only send 1 and 0 at every ~45ms).

As Windows is non-real time multitasking, my application will not run all the time (even if I set it as 'real time' priority) so it may not be active when the time lapses and needs to send the signal. I cannot accept a delay higher than 0.5ms. What kind of delay (jitter) I can expect from Windows?

Ignore the delay added by the USB interface/controller which is always the same. I am interested only in the delay caused by multitasking switching.
0
cubic77
Asked:
cubic77
  • 4
  • 4
  • 2
  • +2
1 Solution
 
dmitry_nCommented:
Expect nothing.  Windows is non-real time OS. Period.
0
 
cubic77Author Commented:
What about the mouse driver which is pretty accurate and seems to work at milisecond precision?
0
 
Ephraim WangoyaCommented:

As much as we bash Windows, it should be accurate with a figure like 45ms. (Its not like we are looking at microseconds). Unless your signalling code itself is taking more than 45ms. Even in that case, just have a timing thread that posts a message to your system to reset the signal
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
cubic77Author Commented:
What about 'real time' priority?
0
 
dmitry_nCommented:
cubic77, it seems. Load Windows with lots of stuff and you will see how mouse behaves.
0
 
Geert GruwezOracle dbaCommented:
if you want real-time (or as close as) then you need to set the level of your thread to real-time priority
and use QueryPerfomanceCounter or WaitForSingleObject or something like that for the trigger

the mouse is set in a high priority thread, that's why it responds so fast
0
 
cubic77Author Commented:
@Geert_Gruwez
Thanks Geert.
So it can be done.
0
 
Geert GruwezOracle dbaCommented:
you can get close, but probably no garantee
you need a plc for something very accurate
0
 
Geert GruwezOracle dbaCommented:
something like a anti-virus can really mess up such a system
0
 
cubic77Author Commented:
>you need a plc for something very accurate
Ya, I imagined that. I was thinking actually to a small board with a microcontroller. I just wanted to know what I can expect from a Windows app.
0
 
SleekProductionsCommented:
Like Geert_Gruwez says thread handling is probably needed. I curious as to whether one would gain anything by writing a service (and then optionally communicating with the service if an GUI is needed).
0
 
Geert GruwezOracle dbaCommented:
most of this is explained here:
http://en.wikipedia.org/wiki/Real-time_operating_system

lately most windows like xp are preemptive scheduling

differences can be found here :
http://en.wikipedia.org/wiki/Co-operative_multitasking

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now