Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Jul 2010
How to implement two periodical processes in C++ under Linux?
I am doing real time programming in C++, under Linux.
I have two processes, let me say A and B. A process is being started periodically, every 5ms. B process is being started every 10ms. The process A is doing data processing. The process B is reading that data and displays it.
I am confused about how to run periodically processes. The problem is that the period of process A should be as much as it is possible accurate (5ms). For the process B it isn't so important.
I have created independent processes, each in one .cpp file, and I am starting them from bash file. Is that OK? I don't have to make child processes in order to have parallel processes?
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
Not a good design. Starting a process every 5ms and another every 10ms is just asking to kill the system. Rather, have two processes running continuously, each with a timer that can be set to expire every 5ms in the data processing code, and 10ms in the process that reads/displays the data.
Why will this kill the system? Just do the math. Starting a process every 5ms will be 200 process starts/stops every second for the dp unit, and 100 starts/stops every second for the reader unit. That's 300 processes per second, which will pretty much shut down the system.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!