Fix multi-threading issues (#2013)
- Implement atomic.fence to ensure a proper memory synchronization order - Destroy exec_env_singleton first in wasm/aot deinstantiation - Change terminate other threads to wait for other threads in wasm_exec_env_destroy - Fix detach thread in thread_manager_start_routine - Fix duplicated lock cluster->lock in wasm_cluster_cancel_thread - Add lib-pthread and lib-wasi-threads compilation to Windows CI
This commit is contained in:
@ -116,6 +116,20 @@ os_thread_signal_inited();
|
||||
#endif /* end of BUILD_TARGET_X86_64/AMD_64 */
|
||||
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK */
|
||||
|
||||
typedef enum os_memory_order {
|
||||
os_memory_order_relaxed,
|
||||
os_memory_order_consume,
|
||||
os_memory_order_acquire,
|
||||
os_memory_order_release,
|
||||
os_memory_order_acq_rel,
|
||||
os_memory_order_seq_cst,
|
||||
} os_memory_order;
|
||||
|
||||
void
|
||||
bh_atomic_thread_fence(int mem_order);
|
||||
|
||||
#define os_atomic_thread_fence bh_atomic_thread_fence
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -10,7 +10,8 @@ add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||
include_directories(${PLATFORM_SHARED_DIR})
|
||||
include_directories(${PLATFORM_SHARED_DIR}/../include)
|
||||
|
||||
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
|
||||
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c
|
||||
${PLATFORM_SHARED_DIR}/*.cpp)
|
||||
|
||||
set (PLATFORM_SHARED_SOURCE ${source_all})
|
||||
|
||||
|
||||
22
core/shared/platform/windows/win_atomic.cpp
Normal file
22
core/shared/platform/windows/win_atomic.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "platform_api_vmcore.h"
|
||||
#include "platform_api_extension.h"
|
||||
|
||||
#if WASM_ENABLE_SHARED_MEMORY != 0
|
||||
|
||||
#include <atomic>
|
||||
|
||||
void
|
||||
bh_atomic_thread_fence(int mem_order)
|
||||
{
|
||||
std::memory_order order =
|
||||
(std::memory_order)(std::memory_order::memory_order_relaxed + mem_order
|
||||
- os_memory_order_relaxed);
|
||||
std::atomic_thread_fence(order);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user