473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to implement two periodical processes in C++ under Linux?

Hello,

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 some change of data. The process B is reading that data and displays it.

I am confused about how to run periodically processes.

Is the only way to create child process? Can I create independent processes on some other way?

Tnx!
Jul 26 '10 #1
6 2296
Banfa
9,065 Expert Mod 8TB
You could use cron
Jul 26 '10 #2
Oralloy
988 Expert 512MB
Banfa,

I don't think cron will work because of the required granularity of 5ms.

I think he'll have to implement a polling loop around clock() and put up with the CPU cost.

Here is a link to a good reference to the<ctime> header.

Good luck.
Jul 28 '10 #3
@Oralloy
Thank you for your time!

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.
Jul 28 '10 #4
Banfa
9,065 Expert Mod 8TB
@Oralloy good point

I suspect you will have trouble getting an accurate 5ms poll time on a standard Linux distro since, in common with most desktop OSes it is not truly real-time. I suspect you will get quite a bit of wobble depending on what other processes are also running.

However I believe there are Linux distros/kernels that properly support real-time programming, unfortunately I could actually point you at any specific implementation.
Jul 28 '10 #5
I understand what you are talking about. I'll try with some timer...
Jul 28 '10 #6
Oralloy
988 Expert 512MB
Well, it all depends on what Marija needs. Unfortunately clock instability is a fact of life. The question, Marija, is how much wobble can your processes stand?

I'm not sure about Linux distributions with guaranteed time slices, although running the driver process at a elevetated priority may help.

If it's possible to implement the processes as threads, and package the whole mess in a single program, that might work. Then run the mess elevated by one priority level or so. Just be certain to yield the processor every iteration around the polling loop.

How you solve this depends on your application, Marija.

If you require guaranteed performance, there's VXWorks, as well.
Jul 28 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Markus Franz | last post by:
Hi. Today I created a script called load.py for using at the command line written in Python 2.3. This script should load as many websites as given on the comand line and print them with a...
5
by: Jon Perez | last post by:
Running the following under Linux creates 3 processes instead of 2. Once the started thread exits, 2 processes still remain. Why? import thread from thread import start_new_thread def...
3
by: Myron Turner | last post by:
I'm not sure whether this question belongs entirely here or in a perl group--but probably it requires knowledge of both. I've written a perl module, currently in use, which does asynchronous...
3
by: Doug Baroter | last post by:
Hi, One of my clients has the following situation. They use Access DB for data update etc. some business functions while they also want to view the Access data quickly and more efficiently in...
1
by: harshaL | last post by:
Guys, Actually i want to implement Doors on Linux using C++ coding, on threads, thing is following Interfaces door_bind, door_call, door_create, door_cred, door_info, door_return,...
3
by: Alex | last post by:
Hi all, I'm looking for some advice on how best to implement storage of access logs into a db/2 8.1.4 database running on a RH 7.2 system. I have 5 (squid) web caches running here that...
8
by: mandydhaliwal | last post by:
Hi all, I am porting a win32 c++ program on Linux which first reads a list of processes and their paths from a file.Then this program should launch all of thesese processes. I tried to...
12
by: Sune | last post by:
Hi all, I want to make data stored in-memory (not disk) available to several processes. My concern is that poorly written C applications with dangling pointers may(will) damage the data in this...
2
by: manontheedge | last post by:
I'm trying to write a program in C on Linux where the child processes get their process images replaced. I have in my code, a few child processes that I forked from a single parent process. I'm...
4
by: Johny | last post by:
To get a number of the http processes running on my Linux( Debia box) I use ps -ef | grep "ttpd" | wc -l But If I want to use to get a number of the http processes from my Python program I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.