ashwathgan Posted August 24, 2015 Report Share Posted August 24, 2015 Hi all I noticed a small behavioral pattern of both the above wait statements and I need a small help in understanding it I have a System C thread as follows: SC_MODULE(Task) { sc_out<bool> output .... .... wait (); ... ... SC_CTOR() { sensitive << event } SC_MODULE(Timer) { sc_in<bool> inp [1]; ..... ... event.notify(N, SC_NS); .... } sc_main() { Task* A = .... Task* B =..... } Now, the thing I observed during simulation is: 1. When I use wait (), first task A thread starts and encounters wait () and then Task B encounters wait (). Thus after the event gets triggered, task B wakes up first and then task A wakes up. 2. But when i use wait (event) instead of wait (), then it happens vice versa. that is, first task A wakes up and then task b wakes up after event is notified from timer mdoule. Why is this behaviour? Thanks in advance for any answer Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted August 24, 2015 Report Share Posted August 24, 2015 Hi, Whenever two processes wait for the same event to appear, they will be triggered and executed in the same delta cycle. The order of execution of processes within one delta cycle is undetermined and implementation (simulator) defined. This is intended because the execution is actally meant to be parallel (at the same time). If you rely on a specific execution order, you should model this explicitly by triggering the processes explicitly in the intended order. Greetings Ralph Quote Link to comment Share on other sites More sharing options...
ashwathgan Posted August 24, 2015 Author Report Share Posted August 24, 2015 Hi Ralph Thanks for the explanation. I could understand it for wait (event) from your explanation. Is there any reason for order of execution of wait () as it executes in opposite order of wait (event) ?? Thanks Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted August 24, 2015 Report Share Posted August 24, 2015 Hi, I don't think that there is any explicit reason. The actual order depends on the implementation of the simulator kernel. This behaviour is caused by the internal handling of lists of runnable processes, i.e., the answer is somewhere in the simulator's source code. Greetings 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.