Changeset 20822
- Timestamp:
- 09/17/07 10:39:32 (1 year ago)
- Files:
-
- juggler/trunk/modules/vapor/vpr/md/NSPR/Thread/ThreadNSPR.h (modified) (1 diff)
- juggler/trunk/modules/vapor/vpr/md/POSIX/Thread/ThreadPosix.cpp (modified) (2 diffs)
- juggler/trunk/modules/vapor/vpr/md/POSIX/Thread/ThreadPosix.h (modified) (2 diffs)
- juggler/trunk/modules/vapor/vpr/md/WIN32/Thread/ThreadWin32.cpp (modified) (2 diffs)
- juggler/trunk/modules/vapor/vpr/md/WIN32/Thread/ThreadWin32.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vapor/vpr/md/NSPR/Thread/ThreadNSPR.h
r20816 r20822 245 245 void setPrio(const VPRThreadPriority prio); 246 246 247 void setRunOn(const unsigned int) 247 /** 248 * Sets the CPU affinity for this thread (the CPU on which this thread 249 * will exclusively run). This implementation does nothing. 250 * 251 * @pre The thread must have been set to be a system-scope thread. The 252 * thread from which this method was invoked must be the same as the 253 * thread spawned by this object. 254 * @post The CPU affinity is set or an exception is thrown. 255 * 256 * @param cpu The CPU on which this thread will run exclusively. This value 257 * is zero-based and therefore must be greater than 0 (zero) and 258 * less than the number of processors available on the computer. 259 * 260 * @throw vpr::IllegalArgumentException 261 * Thrown if the thread spawned through the use of this object is 262 * not the thread from which this method was invoked. 263 * @throw vpr::IllegalArgumentException 264 * Thrown if \p cpu is less than 0. 265 * @throw vpr::IllegalArgumentException 266 * Thrown if this is not a system-scope (i.e., global) thread. 267 * @throw vpr::Exception 268 * Thrown if the CPU affinity for the running thread could not 269 * be changed. 270 * 271 * @note Currently, this method does nothing. 272 * 273 * @since 2.1.6 274 */ 275 void setRunOn(const int) 248 276 { 249 277 /* Do nothing. */ ; 250 278 } 251 279 280 /** 281 * Gets the CPU affinity for this thread (the CPU on which this thread 282 * exclusively runs). This implementation does nothing. 283 * 284 * @pre The thread must have been set to be a system-scope thread, and 285 * a previous affinity must have been set using setRunOn(). The thread 286 * from which this method was invoked must be the same as the thread 287 * spawned by this object. 288 * @post The CPU affinity for this thread is returned to the caller. 289 * 290 * @return The CPU affinity for this thread (posisbly set by a previous 291 * call to setRunOn()). This implementation always returns an 292 * empty vector. 293 * 294 * @throw vpr::IllegalArgumentException 295 * Thrown if the thread spawned through the use of this object is 296 * not the thread from which this method was invoked. 297 * @throw vpr::IllegalArgumentException 298 * Thrown if this is not a system-scope (i.e., global) thread. 299 * @throw vpr::Exception 300 * Thrown if the CPU affinity for the running thread could not 301 * be queried. 302 * 303 * @note Currently, this method does nothing. It always returns an empty 304 * vector. 305 * 306 * @since 2.1.6 307 */ 252 308 std::vector<unsigned int> getRunOn() const 253 309 { juggler/trunk/modules/vapor/vpr/md/POSIX/Thread/ThreadPosix.cpp
r20819 r20822 383 383 } 384 384 385 void ThreadPosix::setRunOn(const unsignedint cpu)385 void ThreadPosix::setRunOn(const int cpu) 386 386 { 387 387 if ( ThreadPosix::self() == this ) 388 388 { 389 if ( cpu < 0 ) 390 { 391 std::ostringstream msg_stream; 392 msg_stream << "Illegal CPU identifier " << cpu << " is less than 0"; 393 throw vpr::IllegalArgumentException(msg_stream.str(), VPR_LOCATION); 394 } 395 389 396 #if defined(VPR_OS_IRIX) 390 397 if ( mScope == VPR_GLOBAL_THREAD ) … … 403 410 cpu_set_t cpu_mask; 404 411 CPU_ZERO(&cpu_mask); 405 CPU_SET( static_cast<int>(cpu), &cpu_mask);412 CPU_SET(cpu, &cpu_mask); 406 413 const int result = sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask); 407 414 juggler/trunk/modules/vapor/vpr/md/POSIX/Thread/ThreadPosix.h
r20816 r20822 314 314 * 315 315 * @param cpu The CPU on which this thread will run exclusively. This value 316 * is zero-based and therefore must be less than the number of317 * processors available on the computer.316 * is zero-based and therefore must be greater than 0 (zero) and 317 * less than the number of processors available on the computer. 318 318 * 319 319 * @throw vpr::IllegalArgumentException 320 320 * Thrown if the thread spawned through the use of this object is 321 321 * not the thread from which this method was invoked. 322 * @throw vpr::IllegalArgumentException 323 * Thrown if \p cpu is less than 0. 322 324 * @throw vpr::IllegalArgumentException 323 325 * Thrown if this is not a system-scope (i.e., global) thread. … … 328 330 * @note Currently, this is only available on IRIX 6.5 and Linux. 329 331 */ 330 void setRunOn(const unsignedint cpu);332 void setRunOn(const int cpu); 331 333 332 334 /** juggler/trunk/modules/vapor/vpr/md/WIN32/Thread/ThreadWin32.cpp
r20817 r20822 306 306 } 307 307 308 void ThreadWin32::setRunOn(const unsignedint cpu)308 void ThreadWin32::setRunOn(const int cpu) 309 309 { 310 310 // Even though we have easy access to mThreadHandle, we perform this test … … 312 312 if ( ThreadWin32::self() == this ) 313 313 { 314 if ( cpu < 0 ) 315 { 316 std::ostringstream msg_stream; 317 msg_stream << "Illegal CPU identifier " << cpu << " is less than 0"; 318 throw vpr::IllegalArgumentException(msg_stream.str(), VPR_LOCATION); 319 } 320 314 321 // The value of cpu is zero-based, but the CPU identifier values from 315 322 // Windows are one-based. juggler/trunk/modules/vapor/vpr/md/WIN32/Thread/ThreadWin32.h
r20816 r20822 271 271 * 272 272 * @param cpu The CPU on which this thread will run exclusively. This value 273 * is zero-based and therefore must be less than the number of274 * processors available on the computer.273 * is zero-based and therefore must be greater than 0 (zero) and 274 * less than the number of processors available on the computer. 275 275 * 276 276 * @throw vpr::IllegalArgumentException 277 277 * Thrown if the thread spawned through the use of this object is 278 278 * not the thread from which this method was invoked. 279 * @throw vpr::IllegalArgumentException 280 * Thrown if \p cpu is less than 0. 279 281 * @throw vpr::Exception 280 282 * Thrown if the CPU affinity for the running thread could not 281 283 * be changed. 284 * 285 * @since 2.1.6 282 286 */ 283 287 void setRunOn(const unsigned int cpu); … … 302 306 * Thrown if the CPU affinity for the running thread could not 303 307 * be queried. 308 * 309 * @since 2.1.6 304 310 */ 305 311 std::vector<unsigned int> getRunOn() const;
