I need to implement a multithreaded pipeline for a real-time application. TBB was a good candidate for that until I found out that its task-scheduler is unfair which makes it unsuitable for real-time applications. Do you have any recommendation on how to implement efficiently such a pipeline in C++ ?
We (I) would have to know detail information as to just what you mean by fair scheduling, what the tasks are, if the tasks are to be preemptible, and many other design considerations.
Real-time applications generally (but not always) have a single producer (interrupt service or timed interval service) than generates task requests. If the tasks have no priority other than first-come, first-serve, then a Single-Producer, Multi-Consumer queue might be sufficient (with event triggers when/if consumer threads need awaking). You may have other requirements than this.
Sorry for this late answer as I was on a long work trip where time was an issue.
Let's put it this way: I am quite new to real-time applications and I am used to do multithreading with OpenMP and TBB. It seems that real-time people tend to launch their own threads and not rely on a threading library. Even though I begin to understand why, this is really new to me. Maybe the best thing for me would be to read something on multithreading for real-time applications but I could not find anything on that subject on the web. Do you have any recommendation where to start?
Can you describe your requirements and runtime environment?
Note, many people (ab)use the term "real-time application". To me, a real-time system is run on a dedicated system where the application has complete control of the runtime environment. IOW there is no operating system... or at least all components of the operating system (library) are under complete control of the application. What this means is you cannot guarantee that real-time latency/response time requirements can be met on any general purpose operating system (Windows, Linux, Mac, etc...). Even a specialize operating system (e.g. RTOS) may have issues with assuring real-time latency/response time requirements.
So, please specify your requirements, expectations and runtime environment (O/S, CPU(s), what other activities may be running on the system,...).
Also, specify if your real-time requirements:
a) only apply to meeting latencies on the input stage
b) or apply to the entire pipeline
Is this latency a fixed requirement (e.g. must not exceed....),
or an averaged latency,
or are you simply looking for the lowest latency (on average) parallel pipeline (with no real-time expectations)