• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

real time software on Windows

think2

Senior member
Is it possible to have a real time application on Windows that continually receives messages on a serial port at 38400 baud and sends an acknowledge to each message where the delay before the ack is sent averages less than 100 milliseconds (or preferably less than 50 ms) and is never more than one or two seconds. The sending end retries a few times if it gets no ack from the PC, then discards the message and signals a fault. The messages being sent to the PC are mostly 30 to 50 bytes and the ack response is around 6 bytes. The sending end can queue approx, say, max 200 messages if the PC doesn't keep up for a short period.

Is it possible to have like a high priority thread or something to help ensure the ack response is sent as quickly as possible so that the sending device never has to discard any messages?
 
Windows isn't a real-time OS so you don't get any timing guarantees. It will probably meet your requirements the majority of the time, but there's nothing preventing it from taking a long time to respond if the machine is under load or something like that. I wouldn't use Windows for controlling something critical.

Windows CE is real-time. If you're looking for something free, I can suggest the Xenomai Linux kernel. I'm currently using that kernel with Ubuntu to control my CNC machine.

http://en.wikipedia.org/wiki/List_of_real-time_operating_systems
 
Last edited:
Windows isn't a real-time OS so you don't get any timing guarantees.

I just found there's a REALTIME_PRIORITY_CLASS for threads. I wonder if I could have a thread that processes a certain number of characters from the serial port then sleeps for 20 milliseconds. I wonder what would the longest time a thread of this priority would be switched out for - hopefully not much more than 20 milliseconds.
 
Interesting. I didn't know that existed.

I've only Googled this for a few minutes, but it looks like that gets you close to real-time, but doesn't actually have any real-time guarantees (i.e. I wouldn't use it to control a pacemaker). Looks like it's probably good enough for what you want to do though, especially since you have some buffer on the sending side.

Just a heads up. It looks like the process needs to be running as administrator for it to work. It looks like a non-administrator process that sets priority to REALTIME_PRIORITY_CLASS actually gets set to HIGH_PRIORITY_CLASS.
 
Back
Top