Solved

Windows application resolution (task switching)

Posted on 2011-02-16
12
798 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:ewangoya
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
 

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 36

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

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

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 36

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 36

Accepted Solution

by:
Geert Gruwez earned 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now