Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows application resolution (task switching)

Posted on 2011-02-16
12
Medium Priority
?
808 Views
Last Modified: 2012-05-11
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
Comment
Question by:cubic77
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 3

Expert Comment

by:dmitry_n
ID: 34907016
Expect nothing.  Windows is non-real time OS. Period.
0
 

Author Comment

by:cubic77
ID: 34907076
What about the mouse driver which is pretty accurate and seems to work at milisecond precision?
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34908439

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:cubic77
ID: 34908703
What about 'real time' priority?
0
 
LVL 3

Expert Comment

by:dmitry_n
ID: 34909822
cubic77, it seems. Load Windows with lots of stuff and you will see how mouse behaves.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 34910378
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
 

Author Comment

by:cubic77
ID: 34910420
@Geert_Gruwez
Thanks Geert.
So it can be done.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 34910432
you can get close, but probably no garantee
you need a plc for something very accurate
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 34910436
something like a anti-virus can really mess up such a system
0
 

Author Comment

by:cubic77
ID: 34910458
>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
 

Expert Comment

by:SleekProductions
ID: 34924377
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
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 34924412
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question