amitk3553 Posted May 2, 2013 Report Posted May 2, 2013 Hello All, Please elaborate the systemc simulation kernel scheduling wrt to following example: Process P1 instruction 1 instruction 2 x.notify(); instruction 3 wait(); Process P2 instruction 1 instruction 2 wait (x); instruction 3 Process P3 instruction 1 instruction 2 instruction 3 wait(); instruction 4 All the above processes are sensitive to same static sensitivity list. So the question is in process P2 does the instruction 3 will get the updated value of instruction 1-2 of the same process P2.?????????? Hope for early reply......... Quote
David Long Posted May 2, 2013 Report Posted May 2, 2013 You have waits in each process so I am assuming they are all sc_threads (otherwise you will get a run-time error). Also, I should point out that by defualt, all processes are executed once, during initialization and will run until either they hit a wait or the end of the function is reached. You have not shown any loops in your processes. This means that each process will die (and cannot be resurected) when it gets to the end. So ... During initialization (at time 0), each process will run, in some unknown order (you must not make any assumptions about which order the processes will be executed in). P1 will run until it hits the wait statement, generating an immediate notification (i.e. in the current sim cycle) on event x. If P2 happens to run before P1, it will stop at the wait(x) statement. Once P1 has run, it will immediately wake up, continue to the end and then die. If P2 runs after P1, it will stop at the wait(x) statement and never wake up - a process must be waiting BEFORE an event is notified in order to respond to it and P1 does not contain a loop so it will not notify x again! P3 runs up until the wait statement. When the event in the static sensitivity list occurs, P1 and P3 will wake up (again we do not know in what order), run to the end and then die. I suggest you take another look at the LRM if this is not the behaviour you were expecting! Regards, Dave amitk3553 and karandeep963 2 Quote
karandeep963 Posted May 2, 2013 Report Posted May 2, 2013 Dear Dave , I would like to know the case considering the SC_THREAD using while(true) loop for all the processes implemented in above. Assuming P2 runs before the P1 and then P1 notifies x and then does P2 will execute in the same simulation cycle????? For the same case, if in process P2 does the instruction 3 will get the updated value of instruction 1-2 of the same process P2.?????? Thanks for support Regards, KS Quote
David Long Posted May 3, 2013 Report Posted May 3, 2013 Hi KS, Before answering your question, it is worth pointing out the way the SystemC scheduler works. After inititialization, it advances time to the earliest time step where there is a scheduled event notification. It adds all processes that are sensitive to that event (or other events at the same time step) into a list of "runnable" processes. It then resumes execution of every process in the list of runnable processes (one at a time) in some non-deterministic order. This is known as the evaluation phase. An immediate event notification can add processes to the list of runnable processes within the current time step, provided such processes are currently waiting for that event. Once the list of runnable processes is empty, the scheduler proceedes to the update phase where primitive channels (such as sc_signal) that have been written to, get updated. These primitive channels may be in the sensitivity list of other processes, in which case there is another iteration of the evaluate and update phases known as a delta cycle. This continues until there are no more events to process at the current time step, when the scheduler advances to the next time step. Now, sssuming all of your processes above are within infinite loops, then after the end of the initialization phase, P1 and P3 will be suspended at their wait() statements and P2 will be waiting for an event on x. When the event in P1 and P3's static sensitivity list happens, both processes get added into the list of runnable processes in the current time step. P1 or P3 will then run. If P1 runs first, it will notify event x immediately, this will add P2 to the list of runnable processes. The next process to run could be either P2 or P3. Since P2 always waits for the event notified by P1, it will always run after P1 in any simulation cycle. It's not clear to me what instruction1,etc are doing. If they are just variables that are being read and written, then P2 could see the values written by P1. However, P3 could be executed after P1 but before P3. In which case P2 would see the values written by P3. We cannot predict what will happen (although the order will always be the same every time the simulation is run). Instruction3 in P2 would see the values of instruction1/2 set by P1 or P3, depending on the order that the scheduler executes the process. Hope that makes it a bit clearer for you. Regards, Dave karandeep963 1 Quote
karandeep963 Posted May 6, 2013 Report Posted May 6, 2013 Thanks Dave for clarifying up-to such a deep level. So the answer to question, that in process P2 does the instruction 3 will get the updated value of instruction 1-2 of the same process P2.? is NO. Considering the case that P2 executes before P1 and P3. Please confirm. "Beginners are learning" Quote
David Long Posted May 7, 2013 Report Posted May 7, 2013 Hi, Because process 2 has to suspend and wait for event x, and because event x is only notified by process 1, the state of the instructions seen by process 2 when it wakes up will alway depend on what has happened in process 1 or process 3. Once a process is active, it will remain active until either it reaches the end of the function or it reaches a wait statement. Only one process can be active at the same time. The SystemC scheduler does not currently allow one process to pre-empt another (this feature might be added to a future version). This confirms your assumption above "So the answer to question, that in process P2 does the instruction 3 will get the updated value of instruction 1-2 of the same process P2.? is NO." Regards, Dave karandeep963 1 Quote
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.