wasm-micro-runtime/core/iwasm/libraries
YAMAMOTO Takashi ea408ab6c0
wasi-nn: add minimum serialization on WASINNContext (#4387)
currently this is not necessary because context (WASINNContext) is
local to instance. (wasm_module_instance_t)

i plan to make a context shared among instances in a cluster when
fixing https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313.
this is a preparation for that direction.

an obvious alternative is to tweak the module instance context APIs
to allow declaring some kind of contexts instance-local. but i feel,
in this particular case, it's more natural to make "wasi-nn handles"
shared among threads within a "process".

note that, spec-wise, how wasi-nn behaves wrt threads is not defined
at all because wasi officially doesn't have threads yet. i suppose, at
this point, that how wasi-nn interacts with wasi-threads is something
we need to define by ourselves, especially when we are using an outdated
wasi-nn version.

with this change, if a thread attempts to access a context while
another thread is using it, we simply make the operation fail with
the "busy" error. this is intended for the mimimum serialization to
avoid problems like crashes/leaks/etc. this is not intended to allow
parallelism or such.

no functional changes are intended at this point yet.

cf.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/4313
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2430
2025-06-20 09:48:55 +08:00
..
debug-engine send an empty/error reply from server (#4362) 2025-06-17 13:00:58 +08:00
lib-pthread Add Windows wamrc and iwasm build in release CI (#3857) 2024-10-17 10:01:56 +08:00
lib-rats Keep fix the CMake compatibility issue (#4180) 2025-04-15 12:51:19 +08:00
lib-socket wasi_socket_ext.c: avoid tls to make this library-friendly (#4338) 2025-06-11 07:46:35 +08:00
lib-wasi-threads fix: correct typos and improve comments across multiple files by codespell (#4116) 2025-03-07 08:21:54 +08:00
libc-builtin libc-builtin: Fix function prototype for wasm_runtime_module_realloc (#3702) 2024-08-13 17:44:58 +08:00
libc-emcc libc-emcc: Use alternate method to check getrandom support (#3848) 2024-10-10 10:57:47 +08:00
libc-uvwasi Bump uvwasi to latest commit #392e1f1 (#4312) 2025-06-03 13:21:17 +08:00
libc-wasi Improve readlinkat_dup() to handle symlink size correctly (#4229) 2025-05-09 14:01:29 +08:00
shared-heap Implement shared heap for AOT (#3815) 2024-09-29 12:50:59 +08:00
simde Keep fix the CMake compatibility issue (#4180) 2025-04-15 12:51:19 +08:00
thread-mgr Implement shared heap for AOT (#3815) 2024-09-29 12:50:59 +08:00
wasi-nn wasi-nn: add minimum serialization on WASINNContext (#4387) 2025-06-20 09:48:55 +08:00