Solved

Windows application resolution (task switching)

Posted on 2011-02-16
12
801 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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 37

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 37

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 37

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 37

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

786 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