From c7f65f7bfbee15bd55a79134eee25daca149f8e3 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 4 Dec 2019 10:55:21 -0500 Subject: [PATCH] Remove system::getThreadTime() and system::setThreadRealTime(). --- include/system.hpp | 4 --- src/system.cpp | 69 ---------------------------------------------- 2 files changed, 73 deletions(-) diff --git a/include/system.hpp b/include/system.hpp index 7048dd0f..c9c06445 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -34,10 +34,6 @@ void removeDirectory(const std::string& path); int getLogicalCoreCount(); /** Sets a name of the current thread for debuggers and OS-specific process viewers. */ void setThreadName(const std::string& name); -/** Sets the current thread to be high-priority. */ -void setThreadRealTime(bool realTime); -/** Returns the number of seconds the current thread has been active. */ -double getThreadTime(); /** Returns the caller's human-readable stack trace with "\n"-separated lines. */ std::string getStackTrace(); /** Opens a URL, also happens to work with PDFs and folders. diff --git a/src/system.cpp b/src/system.cpp index 9310ca58..53cc6492 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -21,7 +21,6 @@ #endif #if defined ARCH_WIN - #define _WIN32_WINNT _WIN32_WINNT_VISTA // for QueryThreadCycleTime #include #include #include @@ -156,74 +155,6 @@ void setThreadName(const std::string& name) { } -void setThreadRealTime(bool realTime) { -#if defined ARCH_LIN - int err; - int policy; - struct sched_param param; - if (realTime) { - // Round-robin scheduler policy - policy = SCHED_RR; - param.sched_priority = sched_get_priority_max(policy); - } - else { - // Default scheduler policy - policy = 0; - param.sched_priority = 0; - } - err = pthread_setschedparam(pthread_self(), policy, ¶m); - assert(!err); - - // pthread_getschedparam(pthread_self(), &policy, ¶m); - // DEBUG("policy %d priority %d", policy, param.sched_priority); -#elif defined ARCH_MAC - // Not yet implemented -#elif defined ARCH_WIN - // Set process class first - if (realTime) { - SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - } - else { - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - } -#endif -} - - -double getThreadTime() { -#if defined ARCH_LIN - struct timespec ts; - clockid_t cid; - pthread_getcpuclockid(pthread_self(), &cid); - clock_gettime(cid, &ts); - return ts.tv_sec + ts.tv_nsec * 1e-9; -#elif defined ARCH_MAC - mach_port_t thread = mach_thread_self(); - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; - thread_basic_info_data_t info; - kern_return_t kr = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &count); - if (kr != KERN_SUCCESS || (info.flags & TH_FLAGS_IDLE) != 0) - return 0.0; - return info.user_time.seconds + info.user_time.microseconds * 1e-6; -#elif defined ARCH_WIN - // FILETIME creationTime; - // FILETIME exitTime; - // FILETIME kernelTime; - // FILETIME userTime; - // GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime, &userTime); - // return ((uint64_t(userTime.dwHighDateTime) << 32) + userTime.dwLowDateTime) * 1e-7; - - uint64_t cycles; - QueryThreadCycleTime(GetCurrentThread(), &cycles); - // HACK Assume that the RDTSC Time-Step Counter instruction is fixed at 2.5GHz. This should only be within a factor of 2 on all PCs. - const double freq = 2.5e9; - return (double) cycles / freq; -#endif -} - - std::string getStackTrace() { int stackLen = 128; void* stack[stackLen];