Troubleshooting
Problem
When using vxWorks and sending large objects by value, the Rose RealTime controller will output a panic message if the stack for the RTController's task is blown.
Cause
By default, when loading and running a model from RoseRT on a VxWorks target, the main task will have a stack size of 50KB and all other RoseRT tasks will have a size of 20KB. Sending and receiving large data can cause the tasks stack to be blown.
Resolving The Problem
If a task is sending large data by value it must have a stack size greater than the size of the data. If the stack size is less than the size of the data, it will have to be increased for the offending tasks.
The Tornado browser stack check will indicate if a stack has been blown. Also, the command "checkStack" can be issued from the Tornado Windshell.
If unsure about how many times a copy is made, override the copy constructor (see the online help under C++ / C++ Reference / Model Properties Reference / C++ Model Element Properties / GenerateDefaultConstructor (Class, C++)) and place a print statement in there as well as the code to do the copy. This will indicate how many times the copy constructor is called.
When sending by value, the copy constructor is called once. Depending on what is done at the receiving end, it may be called again. If the copy constructor is called at the receiving end, the task stack size will have to be increased accordingly for the receiver task as well. Below are examples indicating when the copy constructor is called.
// Receiver transition code
const SomeClass & data2 = *rtdata; // copy constructor not called
const SomeClass data2 = *rtdata; // copy constructor called
const SomeClass * data2 = rtdata; // copy constructor not called
Another solution is to send the large data by reference. While this is more efficient, other issues arise such as making the data thread safe so that two tasks do not modify the data at the same time. Also a memory cleanup policy must be decided so the memory is deleted when it is no longer needed.
Attached is a small model where the copy constructor has been overridden. The high water mark for both the sender and receiver's tasks should be approximately 12KB.
Related Information
Historical Number
157129815
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21132271