wasim6691 Posted January 19, 2018 Report Share Posted January 19, 2018 Hi I have 3 to 4 modules and they have 3 to 4 inputs but to synchronize the timing of inputs as they all have to have specific value only then my THREAD PROCESS should run, I am using value_changed_event inside the THREAD PROCESS of the MODULE by using wait(sig.value_changed_event()). But In some MODULES, I am initializing large arrays and due to this when the value changes then it rerun from the 1st Module to the Last and stops in the mid-way displaying the stack over flow as the exception. What Should be the possible solution for this ? I have Increase the Stack size upto 1Giga but still does not work. Thanks Quote Link to comment Share on other sites More sharing options...
David Black Posted January 19, 2018 Report Share Posted January 19, 2018 Don't use recursion? Remember that the stack size applies to each process (SC_THREAD and SC_METHOD), and the machine you are running on needs to have enough memory to accommodate this. If you have 16 threads running with 1G stack, then you need a machine with 16G just for your threads. Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 19, 2018 Report Share Posted January 19, 2018 Hi @wasim6691, Here is a small set of questions if you can provide some answers it would be helpful: Can you provide details about the development environment?(Linux/Windows) How are you setting up the stack size? Can you modify your code to use dynamically allocated array just for the sake of modelling? Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
wasim6691 Posted January 19, 2018 Author Report Share Posted January 19, 2018 Hi 1) my Development Environment is Windows with Visual Studio 2013 for Desktop 2) In Visual Studio, You have the option in the Linker--- System--- Setting for Stack and Heap Size 3) Yes, This is the only option to use Dynamically Allocated. But Can You suggest me some other option to get out of this Stack over flow Problem. ? Thanks. RECURSION: By recursion I mean that If I am sending input from Module-1 to Module-2 and then I am expecting a result from Module-1 to Module-2 (Here in their processes I am using sig.value_changed_event()) and then after getting the result from Module-1, Module-2 send the input to Module-3. Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted January 19, 2018 Report Share Posted January 19, 2018 Quote But In some MODULES, I am initializing large arrays and due to this when the value changes then it rerun from the 1st Module to the Last and stops in the mid-way displaying the stack over flow as the exception. Do not put large arrays on process stack. Put them into Module instead, and allocate module in heap. Example: Large array on stack: SC_MODULE(top) { SC_CTOR(top){ SC_THREAD(thread); } void thread() { int large_array[1000000000]; // will be allocated on sc_thread stack } }; int sc_main(int , char**) { top top_inst{"top_inst"}; sc_start(); } After refactoring: SC_MODULE(top) { SC_CTOR(top){ SC_THREAD(thread); int large_array[1000000000]; // inside module body } void thread() { } }; int sc_main(int , char**) { auto top_inst = std::make_unique<top>{"top_inst"}; // allocated on heap sc_start(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.