From 0b723174fd7ca6e4a906d8dc66c5ec91b1ea9e17 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 9 Jan 2005 10:24:54 +0000 Subject: [PATCH] Add support for binding a thread to a specific CPU (IRIX only at this time). --- simgear/threads/SGThread.cxx | 2 +- simgear/threads/SGThread.hxx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/simgear/threads/SGThread.cxx b/simgear/threads/SGThread.cxx index 0d6f304c..d786c24a 100644 --- a/simgear/threads/SGThread.cxx +++ b/simgear/threads/SGThread.cxx @@ -4,7 +4,7 @@ # include #else # if defined ( sgi ) && !defined( __GNUC__ ) - // This works arounf a bug triggered when using MipsPro 7.4.1 + // This works around a bug triggered when using MipsPro 7.4.1 // and (at least) IRIX 6.5.20 # include # endif diff --git a/simgear/threads/SGThread.hxx b/simgear/threads/SGThread.hxx index fd7d4e66..fcbc0cb5 100644 --- a/simgear/threads/SGThread.hxx +++ b/simgear/threads/SGThread.hxx @@ -67,9 +67,11 @@ public: /** * Start the underlying thread of execution. + * @param cpu An optional parameter to specify on which CPU to run this + * thread (only supported on IRIX at this time). * @return Pthread error code if execution fails, otherwise returns 0. */ - int start(); + int start( unsigned cpu = 0 ); /** * Sends a cancellation request to the underlying thread. The target @@ -130,10 +132,14 @@ SGThread::~SGThread() } inline int -SGThread::start() +SGThread::start( unsigned cpu ) { int status = pthread_create( &tid, 0, start_handler, this ); assert( status == 0 ); +#if defined( sgi ) + if ( !status && !cpu ) + pthread_setrunon_np( cpu ); +#endif return status; } -- 2.39.5