From 29dfe44c25bd3aa9e8c548ad5444e3c25a4cb003 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=98=95=EC=A3=BC/Common=20Platform=20Lab=28SR=29?= =?utf8?q?/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 5 Dec 2022 09:09:07 +0900 Subject: [PATCH] Introduce preloadThread for launcher (#451) * Introduce preloadThread for launcher --- NativeLauncher/launcher/lib/core_runtime.cc | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/NativeLauncher/launcher/lib/core_runtime.cc b/NativeLauncher/launcher/lib/core_runtime.cc index 5f1be89..25b59a0 100644 --- a/NativeLauncher/launcher/lib/core_runtime.cc +++ b/NativeLauncher/launcher/lib/core_runtime.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -267,6 +268,15 @@ void preload() pluginPreload(); } +static pthread_t preloadThreadId = 0; +static void* preloadThread(void* arg) +{ + _INFO("PreloadThread START\n"); + preload(); + _INFO("PreloadThread END\n"); + pthread_exit(NULL); +} + bool initializeCoreClr(PathManager* pm, const std::string& tpa) { bool ncdbStartupHook = isNCDBStartupHookProvided(); @@ -354,10 +364,10 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) // See https://github.com/dotnet/coreclr/issues/6698 // // libunwind use following methods to unwind stack frame. - // UNW_ARM_METHOD_ALL 0xFF - // UNW_ARM_METHOD_DWARF 0x01 - // UNW_ARM_METHOD_FRAME 0x02 - // UNW_ARM_METHOD_EXIDX 0x04 + // UNW_ARM_METHOD_ALL 0xFF + // UNW_ARM_METHOD_DWARF 0x01 + // UNW_ARM_METHOD_FRAME 0x02 + // UNW_ARM_METHOD_EXIDX 0x04 putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); #endif // __arm__ @@ -466,11 +476,13 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) return -1; } - if (launchMode == LaunchMode::loader) { - - // preload libraries and manage dlls for optimizing startup time - preload(); + // preload libraries and manage dlls for optimizing startup time + int err = pthread_create(&preloadThreadId, NULL, preloadThread, NULL); + if (err) { + _ERR("PreloadThread Creation Failed: %s", strerror(err)); + } + if (launchMode == LaunchMode::loader) { // The debug pipe created in the candidate process has a "User" label. // As a result, smack deny occurs when app process try to access the debug pipe. // Also, since debugging is performed only in standalone mode, @@ -496,7 +508,7 @@ void CoreRuntime::finalize() checkOnTerminate = true; // workaround : to prevent crash while process terminate on profiling mode, - // kill process immediately. + // kill process immediately. // see https://github.com/dotnet/coreclr/issues/26687 if (__isProfileMode) { _INFO("shutdown process immediately."); -- 2.7.4