address spaces of real-time task and standard linux process
Hi All,
Do a standard Linux process and a real-time task (spawned by the standard Linux process with rt_task_create and rt_task_start ) share the same address space? More specifically, I have a C++ program like this:
Class A{
//Definition of a class A
};
RT_TASK demo_task;
void demo(void *arg){
A * pA = (A *)arg;
//Access the passed object via pA, e.g., pA->a...
}
int main(){
...
A *pA = new A;
rt_task_create(&demo_task, "realtime_task", 0, 50, 0); rt_task_start(&demo_task, &demo, (void *)pA);
pause();
}
Can the function demo() correctly access the object created in main()? What if pA is a smart pointer defined in Boost library?
With Many Thanks,
Tom
Quoted 5 lines · On 10/23/2011 01:25 PM, [email protected] wrote:
Hi All,
Do a standard Linux process and a real-time task (spawned by the standard Linux process with
rt_task_createandrt_task_start) share the same address space? More specifically, I have a C++ program like this:
...
Quoted 2 lines
Can the function
demo()correctly access the object created inmain()? What if pA is a smart pointer defined in Boost library?
Yes, yes, and yes (though I didn't look at the actual code, the address space is shared).
For things like smart pointers, just make sure that someone is keeping a reference to the object so the reference count does not go to zero.
hth
- Tom