Hi Experts,
I'm making a "polling-processing" mechanism with systemc. In my original SC env, I have two SC_THREAD in a SC module:
one is "polling_thread", which actually acts as a socket server, polls messages from socket client;
the other SC_THREAD is "processing_thread", which consumes the received messages;
To make "polling_thread" keep active, I simply use some code like:
while (1) {
wait(10, SC_NS);
//polling function to get message from socket
//notify processing_thread to process the message
}
In "processing_thread", I do something like:
while (1) {
wait(notify_ev_from_polling_thread);
//process the message, AND THE LOGIC IS TIME CONSUMING!
}
And it works well.
Now, consider "processing_thread" is the user logic I only care about, for simulation accuracy and deterministic, I only expect "processing_thread" to advance SC simulation time and I can record the behavior by getting SC time, e.g. sc_get_timestamp()
For the above purpose, I'm changing "polling_thread" from a SC_THREAD into an external host thread by e.g. pthread. By following the example code of async_request_update() (
Then, there is only one SC_THREAD left in the SC kernel control which is "processing_thread", and looks like the "wait" in "processing_thread" will cause the kernel switch behavior but there is no other thread controlled by kernel.
I expected to see "processing_thread" keeps waiting until the external thread notify it, and do such turn-around in the while loop. But in fact, sc_start() directly returned when wait() is called in "processing_thread".
I'm wondering, is it my mistake of using something or it's just the systemC mechanism. If so, is there any workaround to my requirement?
thanks!