Main thread spread exception when thread-mgr is enabled (#1889)

And refactor clear_wasi_proc_exit_exception, refer to
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1869
This commit is contained in:
Xu Jun
2023-01-20 08:54:27 +08:00
committed by GitHub
parent cb7ac8fee3
commit cadf9d0ad3
10 changed files with 255 additions and 142 deletions

View File

@ -34,6 +34,18 @@ struct WASMCluster {
uint32 stack_size;
/* Record which segments are occupied */
bool *stack_segment_occupied;
/* When has_exception == true, this cluster should refuse any spawn thread
* requests, this flag can be cleared by calling
* wasm_runtime_clear_exception on instances of any threads of this cluster
*/
bool has_exception;
/* When processing is true, this cluster should refuse any spawn thread
* requests. This is a short-lived state, must be cleared immediately once
* the processing finished.
* This is used to avoid dead lock when one thread waiting another thread
* with lock, see wams_cluster_wait_for_all and wasm_cluster_terminate_all
*/
bool processing;
#if WASM_ENABLE_DEBUG_INTERP != 0
WASMDebugInstance *debug_inst;
#endif
@ -113,9 +125,6 @@ void
wasm_cluster_wait_for_all_except_self(WASMCluster *cluster,
WASMExecEnv *exec_env);
bool
wasm_cluster_add_exec_env(WASMCluster *cluster, WASMExecEnv *exec_env);
bool
wasm_cluster_del_exec_env(WASMCluster *cluster, WASMExecEnv *exec_env);
@ -123,7 +132,7 @@ WASMExecEnv *
wasm_clusters_search_exec_env(WASMModuleInstanceCommon *module_inst);
void
wasm_cluster_spread_exception(WASMExecEnv *exec_env);
wasm_cluster_spread_exception(WASMExecEnv *exec_env, bool clear);
WASMExecEnv *
wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env);