Changeset 5417
- Timestamp:
- 08/10/06 17:50:56
- Files:
-
- OpenThreads/trunk/include/OpenThreads/Thread (modified) (3 diffs)
- OpenThreads/trunk/pthread_src/GNUmakefile (modified) (1 diff)
- OpenThreads/trunk/pthread_src/PThread.c++ (modified) (7 diffs)
- OpenThreads/trunk/pthread_src/PThreadPrivateData.h (modified) (1 diff)
- OpenThreads/trunk/sproc_src/SprocThread.c++ (modified) (2 diffs)
- OpenThreads/trunk/win32_src/Win32Thread.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenThreads/trunk/include/OpenThreads/Thread
r4275 r5417 30 30 31 31 namespace OpenThreads { 32 33 /** 34 * Get the number of processors. 35 * 36 * Note, systems where no support exists for querrying the number of processors, 1 is returned. 37 * 38 */ 39 extern OPENTHREAD_EXPORT_DIRECTIVE int GetNumberOfProcessors(); 40 32 41 33 42 /** … … 130 139 */ 131 140 static ThreadPriority GetMasterPriority() {return s_masterThreadPriority;}; 141 132 142 133 143 /** … … 360 370 */ 361 371 void * _prvData; 362 372 363 373 /** 364 374 * Master thread's priority, set by Thread::Init. OpenThreads/trunk/pthread_src/GNUmakefile
r4901 r5417 41 41 LIB = $(LIB_PREFIX)$(TARGET_BASENAME) 42 42 43 43 ifeq ($(COMPILE_USING_TWO_PARAM_sched_setaffinity),yes) 44 DEF += -DCOMPILE_USING_TWO_PARAM_sched_setaffinity 45 endif 44 46 include $(TOPDIR)/Make/makerules OpenThreads/trunk/pthread_src/PThread.c++
r4275 r5417 35 35 #endif 36 36 37 #if defined (__linux__) 38 #include <sched.h> 39 #endif 40 37 41 #include <OpenThreads/Thread> 38 42 #include "PThreadPrivateData.h" … … 110 114 static_cast<PThreadPrivateData *>(thread->_prvData); 111 115 112 #ifdef __sgi 113 pthread_setrunon_np( pd->cpunum ); 114 #endif 115 116 if (pd->cpunum>=0) 117 { 118 #ifdef __sgi 119 120 pthread_setrunon_np( pd->cpunum ); 121 122 #elif defined (__linux__) && defined(CPU_SET) 123 124 cpu_set_t cpumask; 125 CPU_ZERO( &cpumask ); 126 CPU_SET( pd->cpunum, &cpumask ); 127 128 #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) 129 sched_setaffinity( 0, &cpumask ); 130 #else 131 sched_setaffinity( 0, sizeof(cpumask), &cpumask ); 132 #endif 133 134 #endif 135 } 136 116 137 117 138 ThreadCleanupStruct tcs; … … 355 376 pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT; 356 377 pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT; 378 pd->cpunum = -1; 357 379 358 380 _prvData = static_cast<void *>(pd); … … 482 504 PThreadPrivateData *pd = static_cast<PThreadPrivateData *> (_prvData); 483 505 pd->cpunum = cpunum; 506 if (pd->cpunum<0) return -1; 507 484 508 #ifdef __sgi 509 485 510 int status; 486 511 pthread_attr_t thread_attr; … … 493 518 status = pthread_attr_setscope( &thread_attr, PTHREAD_SCOPE_BOUND_NP ); 494 519 return status; 520 521 #elif defined (__linux__) && defined(CPU_SET) 522 523 524 if (pd->isRunning && Thread::CurrentThread()==this) 525 { 526 cpu_set_t cpumask; 527 CPU_ZERO( &cpumask ); 528 CPU_SET( pd->cpunum, &cpumask ); 529 530 #if defined(COMPILE_USING_TWO_PARAM_sched_setaffinity) 531 return sched_setaffinity( 0, &cpumask ); 532 #else 533 return sched_setaffinity( 0, sizeof(cpumask), &cpumask ); 534 #endif 535 } 536 537 return -1; 495 538 #else 496 539 return -1; … … 828 871 // Use: protected 829 872 // 830 int Thread::YieldCurrentThread() { 873 int Thread::YieldCurrentThread() 874 { 831 875 832 876 return sched_yield(); … … 842 886 return ::usleep(microsec); 843 887 } 888 889 890 891 //----------------------------------------------------------------------------- 892 // 893 // Description: Get the number of processors 894 // 895 int OpenThreads::GetNumberOfProcessors() 896 { 897 #if defined(__linux__) 898 return sysconf(_SC_NPROCESSORS_CONF); 899 #else 900 return 1; 901 #endif 902 } OpenThreads/trunk/pthread_src/PThreadPrivateData.h
r3332 r5417 66 66 volatile int uniqueId; 67 67 68 volatile unsignedint cpunum;68 volatile int cpunum; 69 69 70 70 static int nextId; OpenThreads/trunk/sproc_src/SprocThread.c++
r4275 r5417 350 350 351 351 _prvData = static_cast<void *>(pd); 352 353 352 } 354 353 … … 775 774 776 775 } 776 777 int Thread::setProcessorAffinity( unsigned int cpunum ) 778 { 779 return -1; 780 } 781 782 //----------------------------------------------------------------------------- 783 // 784 // Description: Get the number of processors 785 // 786 int OpenThreads::GetNumberOfProcessors() 787 { 788 return 1; 789 } OpenThreads/trunk/win32_src/Win32Thread.cpp
r5413 r5417 238 238 239 239 pd->stackSize = 0; 240 241 240 pd->isRunning = false; 242 243 241 pd->cancelMode = 0; 244 245 242 pd->uniqueId = 0; 246 247 243 pd->threadPriority = Thread::THREAD_PRIORITY_DEFAULT; 248 249 244 pd->threadPolicy = Thread::THREAD_SCHEDULE_DEFAULT; 250 251 245 pd->detached = false; 252 253 246 pd->cancelEvent.set(CreateEvent(NULL,TRUE,FALSE,NULL)); 254 247 255 248 _prvData = static_cast<void *>(pd); 256 257 249 } 258 250 … … 641 633 #endif 642 634 } 635 636 637 //----------------------------------------------------------------------------- 638 // 639 // Description: Get the number of processors 640 // 641 int OpenThreads::GetNumberOfProcessors() 642 { 643 return 1; 644 }
