mohitnegi Posted August 28, 2014 Report Share Posted August 28, 2014 for suspend/resume #include "systemc.h" class test : public sc_module { public : sc_process_handle t ; SC_HAS_PROCESS(test); test(sc_module_name){ SC_THREAD(run); t = sc_get_current_process_handle(); SC_THREAD(run2); } void run(){ wait(10,SC_NS); cout<<"T :run1 "<<sc_time_stamp().value()<<endl; wait(5,SC_NS); cout<<"T :run2 "<<sc_time_stamp().value()<<endl; } void run2(){ wait(10,SC_NS); cout<<"T :run3 "<<sc_time_stamp().value()<<endl; t.suspend(); //t.disable(); cout<<"T :run4 "<<sc_time_stamp().value()<<endl; wait(20,SC_NS); cout<<"T :run5 "<<sc_time_stamp().value()<<endl; t.resume(); //t.enable(); cout<<"T :run6 "<<sc_time_stamp().value()<<endl; //t.reset(); } }; int sc_main(int, char**){ test t("test"); sc_start(); return 0; } mic-24@localhost tmp]$ ./run.x SystemC 2.3.1-Accellera --- May 1 2014 15:38:34 Copyright (c) 1996-2014 by all Contributors, ALL RIGHTS RESERVED T :run1 10000 T :run3 10000 T :run4 10000 T :run5 30000 T :run6 30000 T :run2 30000 here i dont understand why final value is 30000 not 35000 and what happenened to this "wait(5,SC_NS);" now in disable/resume #include "systemc.h" class test : public sc_module { public : sc_process_handle t ; SC_HAS_PROCESS(test); test(sc_module_name){ SC_THREAD(run); t = sc_get_current_process_handle(); SC_THREAD(run2); } void run(){ wait(10,SC_NS); cout<<"T :run1 "<<sc_time_stamp().value()<<endl; wait(5,SC_NS); cout<<"T :run2 "<<sc_time_stamp().value()<<endl; } void run2(){ wait(10,SC_NS); cout<<"T :run3 "<<sc_time_stamp().value()<<endl; //t.suspend(); t.disable(); cout<<"T :run4 "<<sc_time_stamp().value()<<endl; wait(20,SC_NS); cout<<"T :run5 "<<sc_time_stamp().value()<<endl; //t.resume(); t.enable(); cout<<"T :run6 "<<sc_time_stamp().value()<<endl; //t.reset(); } }; int sc_main(int, char**){ test t("test"); sc_start(); return 0; } [mic-24@localhost tmp]$ ./run.x SystemC 2.3.1-Accellera --- May 1 2014 15:38:34 Copyright (c) 1996-2014 by all Contributors, ALL RIGHTS RESERVED T :run1 10000 T :run3 10000 Error: (E559) Undefined process control interaction: attempt to disable a thread with timeout wait: test.run In file: ../../../../src/sysc/kernel/sc_process.cpp:345 In process: test.run2 @ 10 ns [mic-24@localhost tmp]$ what is the problem here ??? Quote Link to comment Share on other sites More sharing options...
David Black Posted August 28, 2014 Report Share Posted August 28, 2014 First, why are you calling the .value() method? To output time, you should use just sc_time_stamp() or possibly (but not necessary) .to_string() method. cout << sc_time_stamp() << endl; Next, you have a race condition. Process run() and run2() are not guaranteed to start in any particular order with respect to each other. Yes, for a given simulator implementation, one will run before the other, but that is purely based on the implementation. The standard is very specific about this aspect. Next, the error in your disable/enable situation occurs because run2() is attempting to control run(), but run() has already terminated. See http://videos.accellera.org/ieee16662011/index.html for more information. Quote Link to comment Share on other sites More sharing options...
dakupoto Posted August 29, 2014 Report Share Posted August 29, 2014 First, why are you calling the .value() method? To output time, you should use just sc_time_stamp() or possibly (but not necessary) .to_string() method. cout << sc_time_stamp() << endl; Next, you have a race condition. Process run() and run2() are not guaranteed to start in any particular order with respect to each other. Yes, for a given simulator implementation, one will run before the other, but that is purely based on the implementation. The standard is very specific about this aspect. Next, the error in your disable/enable situation occurs because run2() is attempting to control run(), but run() has already terminated. See http://videos.accellera.org/ieee16662011/index.html for more information. In perfect agreement with your comments, it appears that using some of the built-in SystemC synchronization primitives would provide the necessary control. Tricky no doubt. Quote Link to comment Share on other sites More sharing options...
rahuljn Posted September 5, 2014 Report Share Posted September 5, 2014 You cannot disable a thread which is in timed wait Thanks 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.