saraswathi.m Posted December 18, 2013 Report Share Posted December 18, 2013 Hi All, How sc_fork and sc_join is internally implemented? in below code control will not come to end of file. SC_MODULE(top) { void run() { cout " run: before fork/join" << endl; SC_FORK SC_JOIN cout << "run: after fork/join" << endl; } SC_CTOR(top) { SC_THREAD(run); } }; int sc_main(int argc, char **argv) { top top_1("top_1); sc_start(); return 0; } Output : run:before fork/join question : why after fork/join is not printed in this case? Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted December 18, 2013 Report Share Posted December 18, 2013 question : why after fork/join is not printed in this case? Quoting from IEEE 1666-2011, 5.5.7 (emphasis mine): The text between SC_FORK and SC_JOIN shall consist of a series of one or more calls to function sc_spawn separated by commas. Since you don't fork anything, on what do you want to join? /Philipp sumit_tuwien 1 Quote Link to comment Share on other sites More sharing options...
saraswathi.m Posted December 18, 2013 Author Report Share Posted December 18, 2013 if i have a spawned process inside fork/join and property is set to dont_initialize. SC_MODULE(top) { void fun() { cout " =========== fun========" << endl; } sc_spawn_options opt; void run() { opt.dont_initialize(); cout " run: before fork/join" << endl; SC_FORK sc_spawn(sc_bind(&top::fun, this), "d1", &opt), SC_JOIN cout << "run: after fork/join" << endl; } SC_CTOR(top) { SC_THREAD(run); } }; int sc_main(int argc, char **argv) { top top_1("top_1); sc_start(); return 0; } output : before fork/join ================= fun =============== question : i have spawned process inside fork and join still the statement "after fork/join " is not printed.how ? Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted December 18, 2013 Report Share Posted December 18, 2013 if i have a spawned process inside fork/join and property is set to dont_initialize. Spawning a process without static sensitivity and with dont_initialize set makes no sense. This process will never be activated and will just be an orphaned zombie. What are you trying to achieve? An SC_FORK/SC_JOIN block is meant to spawn a set of parallel (sub-)processes, wait for the completion/termination of all of them, and continue the processing of the spawng process afterwards. Since your spawned process will never complete (since it is never activated in the first place), the SC_JOIN statement will never complete either. output : before fork/join ================= fun =============== question : i have spawned process inside fork and join still the statement "after fork/join " is not printed.how ? Im somewhat doubt that you actually see the "fun" line printed to your output. It should not be printed given my answer above. But your code is not the "real" one anyhow (you're missing some stream operators, for example). Please always try to post the real code. /Philipp aarone 1 Quote Link to comment Share on other sites More sharing options...
saraswathi.m Posted December 19, 2013 Author Report Share Posted December 19, 2013 yes "fun" line will not print and Thanks for your explanation regarding fork/join. /Saraswathi Quote Link to comment Share on other sites More sharing options...
dakupoto Posted December 20, 2013 Report Share Posted December 20, 2013 yes "fun" line will not print and Thanks for your explanation regarding fork/join. /Saraswathi Hello Sir/Madam, It is requested that you very carefully look up how SystemC threads are triggered, specifically sensitivity lists. You have: SC_CTOR(top) { SC_THREAD(run); } So which event is the thread triggered on ? Please note that SystemC is an event friven simulator. And then, sc_spawn_options do not need to be used. Why complicate things when there are simpler and more precise methods to tackle a problem ? Quote Link to comment Share on other sites More sharing options...
apfitch Posted December 20, 2013 Report Share Posted December 20, 2013 Hi Dakupoto, every systemc process will run at time 0 regardless of sensitivity. However as Philipp points out, using both dont_initialize() and no sensitivity would cause a process to never run, regards Alan Quote Link to comment Share on other sites More sharing options...
dakupoto Posted December 21, 2013 Report Share Posted December 21, 2013 Hi Dakupoto, every systemc process will run at time 0 regardless of sensitivity. However as Philipp points out, using both dont_initialize() and no sensitivity would cause a process to never run, regards Alan Dear Sir, I fully agree with your point. However, it seems a bit peculiar to use an event driven simulator but not take advantage of the core feature of the tool. Of course the thread will run at time 0, but then what ? Quote Link to comment Share on other sites More sharing options...
apfitch Posted December 22, 2013 Report Share Posted December 22, 2013 Hi Dakupoto, you can still use dynamic sensitivity. For instance a typical TLM2 loosely-timed model would use SC_THREADs with no sensitivity. The events are used dynamically as part of set_and_sync() (for instance), kind regards Alan 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.