Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows application resolution (task switching)

Posted on 2011-02-16
12
Medium Priority
?
806 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 

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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Starting up a Project

715 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