Files
compute-runtime/shared/source/os_interface/linux/os_thread_linux.cpp
Oskar Hubert Weber 38a3667304 fix: avoid joining thread in deferred deleter
Join thread in DllMain (which we are not aware of)
can result in hang occurring in DeferredDeleter, if the library is
freed before FreeLibraryAndExitThread call from within the worker thread,
the thread gets stuck, thus the main thread is stuck on worker->join().

Related-To: NEO-14121

Signed-off-by: Oskar Hubert Weber <oskar.hubert.weber@intel.com>
2025-04-16 10:02:10 +02:00

36 lines
738 B
C++

/*
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/os_thread_linux.h"
#include <sched.h>
namespace NEO {
ThreadLinux::ThreadLinux(pthread_t threadId) : threadId(threadId){};
decltype(&Thread::create) Thread::createFunc = Thread::create;
std::unique_ptr<Thread> Thread::create(void *(*func)(void *), void *arg) {
pthread_t threadId;
pthread_create(&threadId, nullptr, func, arg);
return std::unique_ptr<Thread>(new ThreadLinux(threadId));
}
void ThreadLinux::join() {
pthread_join(threadId, nullptr);
}
void ThreadLinux::detach() {
pthread_detach(threadId);
}
void ThreadLinux::yield() {
sched_yield();
}
} // namespace NEO