Function simics::api::simulator::callbacks::thread_safe_callback

source ·
pub fn thread_safe_callback<F>(cb: F) -> Result<()>
where F: FnOnce() + 'static,
Expand description

Schedule a callback to be run with all execution stopped (global context)

If posted while an instruction is being executed, the callback will be invoked after the current instruction has completed.

This is the function in the Simics API that can be called from threads that are not created by Simics (i.e., from Threaded context).

When the callback is run, it is executed in Global Context, which means that it is safe to call any API functions from it. Another thread in the module may at this time also call API functions, if it synchronizes correctly with the callback function. For example, the callback function might just signal to the foreign thread to do its Simics API calls, wait for the thread to signal that it has finished, and then return.

§Context

Threaded Context Callback: Global Context