Changeset 5876
- Timestamp:
- 01/03/07 17:49:46
- Files:
-
- OpenThreads/trunk/include/OpenThreads/Thread (modified) (1 diff)
- OpenThreads/trunk/pthread_src/PThread.c++ (modified) (1 diff)
- OpenThreads/trunk/sproc_src/SprocThread.c++ (modified) (1 diff)
- OpenThreads/trunk/win32_src/Win32Thread.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenThreads/trunk/include/OpenThreads/Thread
r5495 r5876 39 39 extern OPENTHREAD_EXPORT_DIRECTIVE int GetNumberOfProcessors(); 40 40 41 /** 42 * Set the processor affinity of current thread. 43 * 44 * Note, systems where no support exists no affinity will be set, and -1 will be returned. 45 * 46 */ 47 extern OPENTHREAD_EXPORT_DIRECTIVE int SetProcessorAffinityOfCurrentThread(unsigned int cpunum); 41 48 42 49 /** OpenThreads/trunk/pthread_src/PThread.c++
r5495 r5876 901 901 #endif 902 902 } 903 904 int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) 905 { 906 if (cpunum<0) return -1; 907 908 Thread* thread = Thread::CurrentThread(); 909 if (thread) 910 { 911 return thread->setProcessorAffinity(cpunum); 912 } 913 else 914 { 915 #if defined (__linux__) && defined(CPU_SET) 916 917 cpu_set_t cpumask; 918 CPU_ZERO( &cpumask ); 919 CPU_SET( cpunum, &cpumask ); 920 921 #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) 922 return sched_setaffinity( 0, &cpumask ); 923 #else 924 return sched_setaffinity( 0, sizeof(cpumask), &cpumask ); 925 #endif 926 927 #endif 928 } 929 930 return -1; 931 } OpenThreads/trunk/sproc_src/SprocThread.c++
r5495 r5876 788 788 return 1; 789 789 } 790 791 int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) 792 { 793 if (cpunum<0) return -1; 794 795 Thread* thread = Thread::CurrentThread(); 796 if (thread) 797 { 798 return thread->setProcessorAffinity(cpunum); 799 } 800 else 801 { 802 // non op right now, needs implementation. 803 } 804 } OpenThreads/trunk/win32_src/Win32Thread.cpp
r5495 r5876 646 646 return sysInfo.dwNumberOfProcessors; 647 647 } 648 649 int OpenThreads::SetProcessorAffinityOfCurrentThread(unsigned int cpunum) 650 { 651 if (cpunum<0) return -1; 652 653 Thread* thread = Thread::CurrentThread(); 654 if (thread) 655 { 656 return thread->setProcessorAffinity(cpunum); 657 } 658 else 659 { 660 // non op right now, needs implementation. 661 } 662 }
