diff --git a/webrtc/system_wrappers/interface/thread_wrapper.h b/webrtc/system_wrappers/interface/thread_wrapper.h index 7fbf58c19b..c2c3431f8a 100644 --- a/webrtc/system_wrappers/interface/thread_wrapper.h +++ b/webrtc/system_wrappers/interface/thread_wrapper.h @@ -72,14 +72,6 @@ class ThreadWrapper { // not. virtual bool Start(unsigned int& id) = 0; - // Sets the threads CPU affinity. CPUs are listed 0 - (number of CPUs - 1). - // The numbers in processor_numbers specify which CPUs are allowed to run the - // thread. processor_numbers should not contain any duplicates and elements - // should be lower than (number of CPUs - 1). amount_of_processors should be - // equal to the number of processors listed in processor_numbers. - virtual bool SetAffinity(const int* processor_numbers, - const unsigned int amount_of_processors); - // Stops the spawned thread and waits for it to be reclaimed with a timeout // of two seconds. Will return false if the thread was not reclaimed. // Multiple tries to Stop are allowed (e.g. to wait longer than 2 seconds). diff --git a/webrtc/system_wrappers/source/thread.cc b/webrtc/system_wrappers/source/thread.cc index b5ee7a5430..6f023f8696 100644 --- a/webrtc/system_wrappers/source/thread.cc +++ b/webrtc/system_wrappers/source/thread.cc @@ -28,9 +28,4 @@ ThreadWrapper* ThreadWrapper::CreateThread(ThreadRunFunction func, #endif } -bool ThreadWrapper::SetAffinity(const int* processor_numbers, - const unsigned int amount_of_processors) { - return false; -} - } // namespace webrtc diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc index f45c6e001b..e7fe2fecf2 100644 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ b/webrtc/system_wrappers/source/thread_posix.cc @@ -208,49 +208,6 @@ bool ThreadPosix::Start(unsigned int& thread_id) return true; } -// CPU_ZERO and CPU_SET are not available in NDK r7, so disable -// SetAffinity on Android for now. -#if (defined(WEBRTC_LINUX) && (!defined(WEBRTC_ANDROID))) -bool ThreadPosix::SetAffinity(const int* processor_numbers, - const unsigned int amount_of_processors) { - if (!processor_numbers || (amount_of_processors == 0)) { - return false; - } - cpu_set_t mask; - CPU_ZERO(&mask); - - for (unsigned int processor = 0; - processor < amount_of_processors; - ++processor) { - CPU_SET(processor_numbers[processor], &mask); - } -#if defined(WEBRTC_ANDROID) - // Android. - const int result = syscall(__NR_sched_setaffinity, - pid_, - sizeof(mask), - &mask); -#else - // "Normal" Linux. - const int result = sched_setaffinity(pid_, - sizeof(mask), - &mask); -#endif - if (result != 0) { - return false; - } - return true; -} - -#else -// NOTE: On Mac OS X, use the Thread affinity API in -// /usr/include/mach/thread_policy.h: thread_policy_set and mach_thread_self() -// instead of Linux gettid() syscall. -bool ThreadPosix::SetAffinity(const int* , const unsigned int) { - return false; -} -#endif - void ThreadPosix::SetNotAlive() { CriticalSectionScoped cs(crit_state_); alive_ = false; diff --git a/webrtc/system_wrappers/source/thread_posix.h b/webrtc/system_wrappers/source/thread_posix.h index c2025fd8dc..65e6da8ba5 100644 --- a/webrtc/system_wrappers/source/thread_posix.h +++ b/webrtc/system_wrappers/source/thread_posix.h @@ -35,9 +35,6 @@ class ThreadPosix : public ThreadWrapper { // From ThreadWrapper. virtual void SetNotAlive() OVERRIDE; virtual bool Start(unsigned int& id) OVERRIDE; - // Not implemented on Mac. - virtual bool SetAffinity(const int* processor_numbers, - unsigned int amount_of_processors) OVERRIDE; virtual bool Stop() OVERRIDE; void Run(); diff --git a/webrtc/system_wrappers/source/thread_win.cc b/webrtc/system_wrappers/source/thread_win.cc index bcb95e7ba7..2037a6f5ea 100644 --- a/webrtc/system_wrappers/source/thread_win.cc +++ b/webrtc/system_wrappers/source/thread_win.cc @@ -102,21 +102,6 @@ bool ThreadWindows::Start(unsigned int& thread_id) { return true; } -bool ThreadWindows::SetAffinity(const int* processor_numbers, - const unsigned int amount_of_processors) { - DWORD_PTR processor_bit_mask = 0; - for (unsigned int processor_index = 0; - processor_index < amount_of_processors; - ++processor_index) { - // Convert from an array with processor numbers to a bitmask - // Processor numbers start at zero. - // TODO(hellner): this looks like a bug. Shouldn't the '=' be a '+='? - // Or even better |= - processor_bit_mask = 1 << processor_numbers[processor_index]; - } - return SetThreadAffinityMask(thread_, processor_bit_mask) != 0; -} - void ThreadWindows::SetNotAlive() { alive_ = false; } diff --git a/webrtc/system_wrappers/source/thread_win.h b/webrtc/system_wrappers/source/thread_win.h index 1122676654..6fb7d3163f 100644 --- a/webrtc/system_wrappers/source/thread_win.h +++ b/webrtc/system_wrappers/source/thread_win.h @@ -27,8 +27,6 @@ class ThreadWindows : public ThreadWrapper { virtual ~ThreadWindows(); virtual bool Start(unsigned int& id); - bool SetAffinity(const int* processor_numbers, - const unsigned int amount_of_processors); virtual bool Stop(); virtual void SetNotAlive();