rahuljn Posted August 1, 2014 Report Share Posted August 1, 2014 Hi Guys WIth the below program I was expecting the simulation will be blocked indefinitely but it exits and total simulation time is 0 Can someone tells me why it didn'y gets blocked indefinitely ? #include "systemc.h" SC_MODULE(event_trial){ public: sc_event p1,p2; SC_CTOR(event_trial) { SC_THREAD(process1); SC_THREAD(process2); } void process1(){ while(1){ wait(p2); p1.notify(); } } void process2(){ while(1){ wait(p1); p2.notify(); } }}; int sc_main(int , char**){ event_trial et("et"); sc_start(); cout<<"Simulation time : "<<sc_time_stamp().value()<<endl; } Quote Link to comment Share on other sites More sharing options...
karthickg Posted August 1, 2014 Report Share Posted August 1, 2014 I expect this would be a simulator specific behavior. In the specific simulator where you are executing the code, the scheduler is able to detect that there are no more runable threads (and there are no clocked threads) - and hence quits the simulation. Quote Link to comment Share on other sites More sharing options...
karthickg Posted August 1, 2014 Report Share Posted August 1, 2014 A quick read shows that this behavior is defined in the standard document, section 4.3.4.5 When function sc_start is called without any arguments, the scheduler shall run until there is no remainingactivity, unless otherwise interrupted. In other words, except when sc_stop or sc_pause have been called oran exception has been thrown, control shall only be returned from sc_start when the set of runnableprocesses, the set of update requests, the set of delta notifications and time-outs, and the set of timednotifications and time-outs are all empty. On return from sc_start, the implementation shall set simulationtime equal to the time of the most recent event notification or time-out. Quote Link to comment Share on other sites More sharing options...
dakupoto Posted August 2, 2014 Report Share Posted August 2, 2014 Hi Guys WIth the below program I was expecting the simulation will be blocked indefinitely but it exits and total simulation time is 0 Can someone tells me why it didn'y gets blocked indefinitely ? #include "systemc.h" SC_MODULE(event_trial){ public: sc_event p1,p2; SC_CTOR(event_trial) { SC_THREAD(process1); SC_THREAD(process2); } void process1(){ while(1){ wait(p2); p1.notify(); } } void process2(){ while(1){ wait(p1); p2.notify(); } } }; int sc_main(int , char**){ event_trial et("et"); sc_start(); cout<<"Simulation time : "<<sc_time_stamp().value()<<endl; } Hello Sir, First of all, please consult any good reference on SystemC. Granted that SystemC is basically a ANSI C++ library, there are some very odd things going on. 1. What exactly is the code trying to achieve ? You mention 'blocks' -- but blocking on what ? 2. How or what is triggering the two events the very first time ? 3. Invoking 'sc_start' without any arguments would not do anything useful. Hope that helps. 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.