Skip to content

Thread model for embedding WAMR in a multi-threaded environment #3697

Answered by wenyongh
adazh asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, I try to answer the questions:

  • yes, had better call wasm_runtime_init once
  • accessing wasm_module_t in multiple threads when multi-module feature is enabled: normally it is good as long as the module is loaded, note that no lock is acquired when accessing module's multi-module related fields, e.g., module->import_module_list.
  • no need to call wasm_runtime_init_thread_env if the thread is created by runtime or runtime API, e.g. using wasm_runtime_spawn_thread. Only call it if the thread is created by host native itself (e.g. pthread_create), and please call it at the beginning of thread callback, and call wasm_runtime_destroy_thread_env at the end of thread callback.
  • had better not shar…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adazh
Comment options

Answer selected by adazh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants