MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / run_os_threads

Function run_os_threads

3rd/mimalloc-2.0.9/test/test-stress.c:286–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286static void run_os_threads(size_t nthreads, void (*fun)(intptr_t)) {
287 thread_entry_fun = fun;
288 DWORD* tids = (DWORD*)custom_calloc(nthreads,sizeof(DWORD));
289 HANDLE* thandles = (HANDLE*)custom_calloc(nthreads,sizeof(HANDLE));
290 for (uintptr_t i = 0; i < nthreads; i++) {
291 thandles[i] = CreateThread(0, 8*1024, &thread_entry, (void*)(i), 0, &tids[i]);
292 }
293 for (size_t i = 0; i < nthreads; i++) {
294 WaitForSingleObject(thandles[i], INFINITE);
295 }
296 for (size_t i = 0; i < nthreads; i++) {
297 CloseHandle(thandles[i]);
298 }
299 custom_free(tids);
300 custom_free(thandles);
301}
302
303static void* atomic_exchange_ptr(volatile void** p, void* newval) {
304#if (INTPTR_MAX == INT32_MAX)

Callers 2

test_stressFunction · 0.85
test_leakFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected