Previous - Up - Next

8.3   Using Threads in Simics Modules

It is possible to write modules for Simics that use POSIX threads, though the Simics API functions can only be called from the main Simics thread. For another thread to get control of the main thread, it can call the only thread-safe Simics API function SIM_thread_safe_callback(). This function will install a callback that Simics main thread will call as soon as possible, even if Simics is at prompt waiting for a command input.

When the user-installed callback is run, it is executed in the main Simics thread, and it is safe to call API functions from there. Another thread in the module may at this time also call API functions, if it synchronizes correctly with the callback function.

Some support functions for C/C++ programmers, that are not really part of the Simics API, are also safe to call from a thread. This includes the vtprintf() family of functions, such as pr(), and also the VTMEM malloc routines.

Previous - Up - Next