Schedule task at exact times on Linux or Windows

I have this weird question. I would like to know if it is possible to create a program in C / C ++ that will run on Linux or Windows and will handle the interrupt handler according to the system timer set for a certain period (for example, 2000 times per second), and I want to so that this interruption should be with the highest priority, which means that it must be executed every half millisecond, and when it is executed it cannot be interrupted.

We did this with MS-DOS with Borland Turbo C 3.1. We have an interface card (ours) that works in the ISA slot. Every half millisecond, our program reads the state of the electronics that controls the industrial process through an interface. This has worked for us over the past 15 years, but we are running out of motherboards with an ISA connector, so we are looking for new solutions.

We also have a solution based on PIC microcontrollers, but our horizons will be expanded with a general-purpose processor.

I assume that there are some custom Linux kernels for embedded applications, so I'm looking for some sources with which we can start experimenting.

+4
source share
3 answers

Yes, you can do it in MS-DOS, because it is not a multi-user or multi-tasking operating system. However, the same will not work on Windows, as it is a multi-user and multi-tasking operating system. It is also not in real time, which means that there is no guarantee that your task will be completed exactly when you ask it to be completed. Everything is deliberately planned, which means that any number of other processes and tasks (either user or system level) can effectively "raise" your process in the priority list and make it wait for execution until these other tasks are completed or themselves were interrupted to give your process a chance to run for a while.

I do not know about Linux, but I believe that most major distributions are written similarly to Windows.

To do this, you need to find a real-time operating system for one user. A Unix derivative is probably the best place to start your search, but I will not be the person able to offer it.

Alternatively, you can continue to use MS-DOS (or alternatives such as FreeDOS), but switch to another interface technology available on newer boards. There is no reason to update something that works for you, especially if updates are counterproductive for your purpose.

+6
source

A typical OS, such as standard Linux or Windows, is not designed and will not be able to perform this degree of accuracy and availability in real time.

It seems to me that you need to research in real time Linux or the like.

RTLinux is a modified version of the Linux kernel that is designed to work in real time, which is especially important for such applications.

Hope this helps.

+2
source

Personal and low-cost computing over the years has increased in productivity, with the exception of one low-latency area. The delay actually increased in many cases when you are comparing a 486 and a modern desktop processor.

However, check out this article , in which the authors conclude that submillisecond scheduling is possible on Linux for commodity hardware.

0
source

All Articles