Closed wuryel closed 4 years ago
This seems to be part of an even bigger issue that pops up when having tasks embedded in components.
When the task function (generated from Task
, TaskInComponent
) that is transformed into a Runnable
(see step 2 above) is transformed back into a Function
it is (like all runnables) augmented with an additional parameter void* ___id
to hold a reference to the component instance data.
This task function is registered with the 'pthread_create' at the OS (code generation for this doesn't work, see above).
This additional parameter (___id
) does not hold valid data when the function is called back from the OS and as a consequence all accesses to component data within the task function will result in a segmentation fault.
So, if I understood this correctly, in order to have the data available in the task, we'll need to add a reference to the component instance data to the task, see here and here, respectivelly. For the task function the transformation of a runnable to a function as done here is invalid also: The additional parameter ´___id´ is invalid and the component instance data must be retrieved from the task data.
Code generation for components with embedded tasks works fine (only) if the component instance is visible from the component definition. (e.g. in the same implementation module or in an imported implementation module).
This is since the NameOfFunctionExpression is reduced to a NameOfComponentReferenceFunction that requires a component instance.
When transforming
CyclicConstraint
as child child ofScheduleSpecificationInComponent
the reference to the function implementing the task is lost using thegeneration strategy pthreads
for concurrency. 1) TheTaskInComponent
is transformed into aFunction
. This task function is refered to by thenameof<Function>
as parameter ofpthread_create(...)
. 2) The task function is transformed into aRunnable
and the reference withinnameof<Function>
is lost.This seems to be related to #517
For example, the following code doesn't transform correctly: