diff --git a/rtt/Activity.cpp b/rtt/Activity.cpp index d6aa9714d..3a8d62e24 100644 --- a/rtt/Activity.cpp +++ b/rtt/Activity.cpp @@ -53,22 +53,27 @@ namespace RTT using namespace detail; Activity::Activity(RunnableInterface* _r, const std::string& name ) - : ActivityInterface(_r), os::Thread(ORO_SCHED_OTHER, 0, 0.0, name ) + : ActivityInterface(_r), os::Thread(ORO_SCHED_OTHER, 0, 0.0, ~0, name ) { } Activity::Activity(int priority, RunnableInterface* r, const std::string& name ) - : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, 0.0, name ) + : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, 0.0, ~0, name ) { } Activity::Activity(int priority, Seconds period, RunnableInterface* r, const std::string& name ) - : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, period, name ) + : ActivityInterface(r), os::Thread(ORO_SCHED_RT, priority, period, ~0, name ) { } Activity::Activity(int scheduler, int priority, Seconds period, RunnableInterface* r, const std::string& name ) - : ActivityInterface(r), os::Thread(scheduler, priority, period, name ) + : ActivityInterface(r), os::Thread(scheduler, priority, period, ~0, name ) + { + } + + Activity::Activity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, RunnableInterface* r, const std::string& name ) + : ActivityInterface(r), os::Thread(scheduler, priority, period, cpu_affinity, name ) { } @@ -149,4 +154,15 @@ namespace RTT bool Activity::isPeriodic() const { return Thread::isPeriodic(); } + + unsigned Activity::getCpuAffinity() const + { + return Thread::getCpuAffinity(); + } + + bool Activity::setCpuAffinity(unsigned cpu) + { + return Thread::setCpuAffinity(cpu); + } + } diff --git a/rtt/Activity.hpp b/rtt/Activity.hpp index ad9da6fcd..d87f42d2c 100644 --- a/rtt/Activity.hpp +++ b/rtt/Activity.hpp @@ -118,6 +118,25 @@ namespace RTT Activity(int scheduler, int priority, Seconds period, base::RunnableInterface* r = 0, const std::string& name ="Activity"); + /** + * @brief Create an Activity with a given scheduler type, priority, period and cpu affinity. + * + * @param scheduler + * The scheduler in which the activity's thread must run. Use ORO_SCHED_OTHER or + * ORO_SCHED_RT. + * @param priority + * The priority of this activity. + * @param period + * The periodicity of the Activity + * @param cpu_affinity + * The prefered cpu to run on (a mask) + * @param r + * The optional base::RunnableInterface to run exclusively within this Activity + * @param name The name of the underlying thread. + */ + Activity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, + base::RunnableInterface* r = 0, const std::string& name ="Activity"); + /** * Stops and terminates a Activity */ @@ -141,6 +160,10 @@ namespace RTT virtual bool setPeriod(Seconds period); + virtual unsigned getCpuAffinity() const; + + virtual bool setCpuAffinity(unsigned cpu); + virtual os::ThreadInterface* thread(); /** diff --git a/rtt/TaskContext.cpp b/rtt/TaskContext.cpp index 6d7fb7953..98d184143 100644 --- a/rtt/TaskContext.cpp +++ b/rtt/TaskContext.cpp @@ -107,6 +107,8 @@ namespace RTT this->addOperation("isRunning", &TaskContext::isRunning, this, ClientThread).doc("Is this TaskContext started ?"); this->addOperation("getPeriod", &TaskContext::getPeriod, this, ClientThread).doc("Get the configured execution period. -1.0: no thread associated, 0.0: non periodic, > 0.0: the period."); this->addOperation("setPeriod", &TaskContext::setPeriod, this, ClientThread).doc("Set the execution period in seconds.").arg("s", "Period in seconds."); + this->addOperation("getCpuAffinity", &TaskContext::getCpuAffinity, this, ClientThread).doc("Get the configured cpu affinity."); + this->addOperation("setCpuAffinity", &TaskContext::setCpuAffinity, this, ClientThread).doc("Set the cpu affinity.").arg("cpu", "Cpu mask."); this->addOperation("isActive", &TaskContext::isActive, this, ClientThread).doc("Is the Execution Engine of this TaskContext active ?"); this->addOperation("inFatalError", &TaskContext::inFatalError, this, ClientThread).doc("Check if this TaskContext is in the FatalError state."); this->addOperation("error", &TaskContext::error, this, ClientThread).doc("Enter the RunTimeError state (= errorHook() )."); diff --git a/rtt/base/ActivityInterface.hpp b/rtt/base/ActivityInterface.hpp index 8233de683..ff394a1ce 100644 --- a/rtt/base/ActivityInterface.hpp +++ b/rtt/base/ActivityInterface.hpp @@ -161,6 +161,20 @@ namespace RTT */ virtual bool setPeriod(Seconds s) = 0; + + /** + * Get the cpu affinity of this activity + * + * @return The cpu affinity of this activity. + */ + virtual unsigned getCpuAffinity() const = 0; + + /** + * Set the cpu affinity of this activity. + * @return true if it could be updated, false otherwise. + */ + virtual bool setCpuAffinity(unsigned cpu) = 0; + /** * Execute this activity such that it \a executes a step or loop of the RunnableInterface. * When you invoke execute() you intend to call the step() or loop() methods. diff --git a/rtt/base/TaskCore.cpp b/rtt/base/TaskCore.cpp index d49c3bd60..7e45852f5 100644 --- a/rtt/base/TaskCore.cpp +++ b/rtt/base/TaskCore.cpp @@ -269,7 +269,7 @@ namespace RTT { return this->engine() && this->engine()->getActivity() && this->engine()->getActivity()->isActive(); } - double TaskCore::getPeriod() const + Seconds TaskCore::getPeriod() const { return this->engine()->getActivity() ? this->engine()->getActivity()->getPeriod() : -1.0; } @@ -279,6 +279,16 @@ namespace RTT { return this->engine()->getActivity() ? this->engine()->getActivity()->setPeriod(s) : false; } + unsigned TaskCore::getCpuAffinity() const + { + return this->engine()->getActivity() ? this->engine()->getActivity()->getCpuAffinity() : ~0; + } + + bool TaskCore::setCpuAffinity(unsigned cpu) + { + return this->engine()->getActivity() ? this->engine()->getActivity()->setCpuAffinity(cpu) : false; + } + bool TaskCore::configureHook() { return true; } diff --git a/rtt/base/TaskCore.hpp b/rtt/base/TaskCore.hpp index 137898f19..16d5ef9f5 100644 --- a/rtt/base/TaskCore.hpp +++ b/rtt/base/TaskCore.hpp @@ -242,6 +242,19 @@ namespace RTT */ virtual bool setPeriod(Seconds s); + /** + * Get the configured cpu affinity of this component. + * @see ActivityInterface::getCpuAffinity() + */ + virtual unsigned getCpuAffinity() const; + + /** + * Sets the cpu affinity of this component. + * @return false if not allowed by the component's activity. + * @see ActivityInterface::setCpuAffinity() + */ + virtual bool setCpuAffinity(unsigned cpu); + /** * Inspect if the component is in the FatalError state. * There is no possibility to recover from this state. diff --git a/rtt/extras/PeriodicActivity.cpp b/rtt/extras/PeriodicActivity.cpp index a71ba90e8..13cfe2104 100644 --- a/rtt/extras/PeriodicActivity.cpp +++ b/rtt/extras/PeriodicActivity.cpp @@ -63,6 +63,13 @@ namespace RTT { this->init(); } + PeriodicActivity::PeriodicActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, RunnableInterface* r ) + : ActivityInterface(r), running(false), active(false), + thread_( TimerThread::Instance(scheduler, priority, period, cpu_affinity) ) + { + this->init(); + } + PeriodicActivity::PeriodicActivity(TimerThreadPtr thread, RunnableInterface* r ) : ActivityInterface(r), running(false), active(false), thread_( thread ) @@ -158,6 +165,16 @@ namespace RTT { return false; } + unsigned PeriodicActivity::getCpuAffinity() const + { + return thread_->getCpuAffinity(); + } + + bool PeriodicActivity::setCpuAffinity(unsigned cpu) + { + return thread_->setCpuAffinity(cpu); + } + bool PeriodicActivity::initialize() { if (runner != 0) return runner->initialize(); diff --git a/rtt/extras/PeriodicActivity.hpp b/rtt/extras/PeriodicActivity.hpp index 30ec2c073..7f11630ab 100644 --- a/rtt/extras/PeriodicActivity.hpp +++ b/rtt/extras/PeriodicActivity.hpp @@ -104,6 +104,25 @@ namespace RTT */ PeriodicActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* r=0 ); + /** + * @brief Create a Periodic Activity with a given scheduler type, priority and period. + * + * @param scheduler + * The scheduler in which the activitie's thread must run. Use ORO_SCHED_OTHER or + * ORO_SCHED_RT. + * @param priority + * The priority of this activity. A lookup will be done to locate a suitable + * TimerThread with the same priority. If it exists and it has the same \a period, + * this activity will be executed in that thread. Otherwise, a new TimerThread is created. + * @param period + * The periodicity of the PeriodicActivity + * @param cpu_affinity + * The prefered cpu to run on (a mask) + * @param r + * The optional base::RunnableInterface to run exclusively within this Activity + */ + PeriodicActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity, base::RunnableInterface* r=0 ); + /** * @brief Create a Periodic Activity executing in a given thread. @@ -167,6 +186,10 @@ namespace RTT virtual bool setPeriod(Seconds s); + virtual unsigned getCpuAffinity() const; + + virtual bool setCpuAffinity(unsigned cpu); + virtual os::ThreadInterface* thread(); /** diff --git a/rtt/extras/SequentialActivity.cpp b/rtt/extras/SequentialActivity.cpp index aefefa21b..fc2e39dd8 100644 --- a/rtt/extras/SequentialActivity.cpp +++ b/rtt/extras/SequentialActivity.cpp @@ -65,6 +65,16 @@ namespace RTT { return false; } + unsigned SequentialActivity::getCpuAffinity() const + { + return ~0; + } + + bool SequentialActivity::setCpuAffinity(unsigned cpu) + { + return false; + } + os::ThreadInterface* SequentialActivity::thread() { return os::MainThread::Instance(); diff --git a/rtt/extras/SequentialActivity.hpp b/rtt/extras/SequentialActivity.hpp index 6c3252b05..9da74ca0c 100644 --- a/rtt/extras/SequentialActivity.hpp +++ b/rtt/extras/SequentialActivity.hpp @@ -87,6 +87,10 @@ namespace RTT bool setPeriod(Seconds s); + unsigned getCpuAffinity() const; + + bool setCpuAffinity(unsigned cpu); + os::ThreadInterface* thread(); bool initialize(); diff --git a/rtt/extras/SlaveActivity.cpp b/rtt/extras/SlaveActivity.cpp index 15ef8dcd3..3c399790a 100644 --- a/rtt/extras/SlaveActivity.cpp +++ b/rtt/extras/SlaveActivity.cpp @@ -76,6 +76,18 @@ namespace RTT { return true; } + unsigned SlaveActivity::getCpuAffinity() const + { + if (mmaster) + return mmaster->getCpuAffinity(); + return ~0; + } + + bool SlaveActivity::setCpuAffinity(unsigned cpu) + { + return false; + } + os::ThreadInterface* SlaveActivity::thread() { return mmaster ? mmaster->thread() : os::MainThread::Instance(); diff --git a/rtt/extras/SlaveActivity.hpp b/rtt/extras/SlaveActivity.hpp index 5b77b9b01..bb6e871b2 100644 --- a/rtt/extras/SlaveActivity.hpp +++ b/rtt/extras/SlaveActivity.hpp @@ -122,6 +122,10 @@ namespace RTT bool setPeriod(Seconds s); + unsigned getCpuAffinity() const; + + bool setCpuAffinity(unsigned cpu); + os::ThreadInterface* thread(); bool initialize(); diff --git a/rtt/extras/TimerThread.cpp b/rtt/extras/TimerThread.cpp index dd4837929..cbd7ff17a 100644 --- a/rtt/extras/TimerThread.cpp +++ b/rtt/extras/TimerThread.cpp @@ -59,6 +59,11 @@ namespace RTT { } TimerThreadPtr TimerThread::Instance(int scheduler, int pri, double per) + { + return Instance(scheduler, pri, per, ~0); + } + + TimerThreadPtr TimerThread::Instance(int scheduler, int pri, double per, unsigned cpu_affinity) { // Since the period is stored as nsecs, we convert per to NS in order // to get a match. @@ -77,19 +82,19 @@ namespace RTT { } ++it; } - TimerThreadPtr ret( new TimerThread(scheduler, pri, "TimerThreadInstance", per) ); + TimerThreadPtr ret( new TimerThread(scheduler, pri, "TimerThreadInstance", per, cpu_affinity) ); TimerThreads.push_back( ret ); return ret; } - TimerThread::TimerThread(int priority, const std::string& name, double periodicity) - : Thread( ORO_SCHED_RT, priority, periodicity, name), cleanup(false) + TimerThread::TimerThread(int priority, const std::string& name, double periodicity, unsigned cpu_affinity) + : Thread( ORO_SCHED_RT, priority, periodicity, cpu_affinity, name), cleanup(false) { tasks.reserve(MAX_ACTIVITIES); } - TimerThread::TimerThread(int scheduler, int priority, const std::string& name, double periodicity) - : Thread(scheduler, priority, periodicity, name), cleanup(false) + TimerThread::TimerThread(int scheduler, int priority, const std::string& name, double periodicity, unsigned cpu_affinity) + : Thread(scheduler, priority, periodicity, cpu_affinity, name), cleanup(false) { tasks.reserve(MAX_ACTIVITIES); } diff --git a/rtt/extras/TimerThread.hpp b/rtt/extras/TimerThread.hpp index 372be2a2f..7cf96d71c 100644 --- a/rtt/extras/TimerThread.hpp +++ b/rtt/extras/TimerThread.hpp @@ -82,7 +82,7 @@ namespace RTT * @param periodicity * The periodicity of this thread in seconds (e.g. 0.001 = 1000Hz ) */ - TimerThread(int priority, const std::string& name, double periodicity); + TimerThread(int priority, const std::string& name, double periodicity, unsigned cpu_affinity = ~0); /** * Create a periodic Timer thread with a given scheduler type. @@ -94,7 +94,7 @@ namespace RTT * @param periodicity * The periodicity of this thread in seconds (e.g. 0.001 = 1000Hz ) */ - TimerThread(int scheduler, int priority, const std::string& name, double periodicity); + TimerThread(int scheduler, int priority, const std::string& name, double periodicity, unsigned cpu_affinity = ~0); /** * Destructor @@ -118,6 +118,10 @@ namespace RTT * Create a TimerThread with a given scheduler, priority and periodicity. */ static TimerThreadPtr Instance(int scheduler, int priority, double periodicity); + /** + * Create a TimerThread with a given scheduler, priority and periodicity. + */ + static TimerThreadPtr Instance(int scheduler, int priority, double periodicity, unsigned cpu_affinity); protected: virtual bool initialize(); virtual void step(); diff --git a/rtt/os/Thread.cpp b/rtt/os/Thread.cpp index 386a4daf1..895c16d34 100644 --- a/rtt/os/Thread.cpp +++ b/rtt/os/Thread.cpp @@ -236,7 +236,7 @@ namespace RTT { } Thread::Thread(int scheduler, int _priority, - Seconds periods, const std::string & name) : + Seconds periods, unsigned cpu_affinity, const std::string & name) : msched_type(scheduler), active(false), prepareForExit(false), inloop(false),running(false), maxOverRun(OROSEM_OS_PERIODIC_THREADS_MAX_OVERRUN), @@ -245,10 +245,10 @@ namespace RTT { ,d(NULL) #endif { - this->setup(_priority, name); + this->setup(_priority, cpu_affinity, name); } - void Thread::setup(int _priority, const std::string& name) + void Thread::setup(int _priority, unsigned cpu_affinity, const std::string& name) { Logger::In in("Thread"); int ret; @@ -286,7 +286,7 @@ namespace RTT { } } #endif - int rv = rtos_task_create(&rtos_task, _priority, name.c_str(), + int rv = rtos_task_create(&rtos_task, _priority, cpu_affinity, name.c_str(), msched_type, default_stack_size, thread_function, this); if (rv != 0) { @@ -308,6 +308,7 @@ namespace RTT { Logger::In in2(modname); log(Info) << "Thread created with scheduler type '" << getScheduler() << "', priority " << getPriority() + << ", cpu affinity " << getCpuAffinity() << " and period " << getPeriod() << "." << endlog(); #ifdef OROPKG_OS_THREAD_SCOPE if (d) @@ -580,6 +581,16 @@ namespace RTT { return period; } + bool Thread::setCpuAffinity(unsigned cpu_affinity) + { + return rtos_task_set_cpu_affinity(&rtos_task, cpu_affinity) == 0; + } + + unsigned Thread::getCpuAffinity() const + { + return rtos_task_get_cpu_affinity(&rtos_task); + } + void Thread::yield() { rtos_task_yield( &rtos_task ); diff --git a/rtt/os/Thread.hpp b/rtt/os/Thread.hpp index b89628ad8..b173fadcb 100644 --- a/rtt/os/Thread.hpp +++ b/rtt/os/Thread.hpp @@ -118,10 +118,11 @@ namespace RTT * @param scheduler The scheduler, one of ORO_SCHED_RT or ORO_SCHED_OTHER. * @param priority The priority of the thread, this is interpreted by your RTOS. * @param period The period in seconds (eg 0.001) of the thread, or zero if not periodic. + * @param cpu_affinity The cpu affinity of the thread, this is interpreted by your RTOS. * @param name The name of the Thread. May be used by your OS to identify the thread. * the thread's own virtual functions are executed. */ - Thread(int scheduler, int priority, double period, + Thread(int scheduler, int priority, double period, unsigned cpu_affinity, const std::string & name); virtual ~Thread(); @@ -188,6 +189,18 @@ namespace RTT virtual int getPriority() const; + /** + * Set cpu affinity for this thread + * @cpu_affinity The cpu affinity of the thread (@see rtos_task_set_cpu_affinity). + * @return true if the mask has been applied + */ + virtual bool setCpuAffinity(unsigned cpu_affinity); + + /** + * @return the cpu affinity (@see rtos_task_set_cpu_affinity) + */ + virtual unsigned getCpuAffinity() const; + virtual void yield(); virtual void setMaxOverrun(int m); @@ -233,7 +246,7 @@ namespace RTT private: Thread(const Thread&); - void setup(int _priority, const std::string& name); + void setup(int _priority, unsigned cpu_affinity, const std::string& name); /** * Do configuration actions when the thread is stopped. diff --git a/rtt/os/ecos/fosi_internal.cpp b/rtt/os/ecos/fosi_internal.cpp index f6b354b7d..e67c06a3e 100644 --- a/rtt/os/ecos/fosi_internal.cpp +++ b/rtt/os/ecos/fosi_internal.cpp @@ -56,6 +56,7 @@ namespace RTT INTERNAL_QUAL int rtos_task_create(RTOS_TASK * task, int priority, + unsigned cpu_affinity, const char * name, int sched_type, size_t stack_size, @@ -205,6 +206,16 @@ namespace RTT return (int) cyg_thread_get_priority(t->handle); } + INTERNAL_QUAL int rtos_task_set_cpu_affinity(RTOS_TASK * task, unsigned cpu_affinity) + { + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + return ~0; + } + INTERNAL_QUAL int rtos_task_set_scheduler(RTOS_TASK* t, int sched_type) { if (sched_type == SCHED_ECOS_FIFO ) return 0; diff --git a/rtt/os/fosi_internal_interface.hpp b/rtt/os/fosi_internal_interface.hpp index dff3cf2e8..f76ab3135 100644 --- a/rtt/os/fosi_internal_interface.hpp +++ b/rtt/os/fosi_internal_interface.hpp @@ -79,6 +79,7 @@ namespace RTT { * @param task An uninitialised, by the user allocated struct which will be * used to store the task data in. * @param priority The priority of the thread, to be interpreted by the underlying RTOS. + * @param cpu_affinity The cpu affinity of the thread (@see rtos_task_set_cpu_affinity). * @param name The name for the thread, or null if none is given. * @param sched_type The scheduler type, one of ORO_SCHED_OTHER, ORO_SCHED_RT or a value * defined by your RTOS. @@ -90,6 +91,7 @@ namespace RTT { */ int rtos_task_create(RTOS_TASK* task, int priority, + unsigned cpu_affinity, const char * name, int sched_type, size_t stack_size, @@ -214,6 +216,23 @@ namespace RTT { */ int rtos_task_get_priority(const RTOS_TASK * task); + /** + * Set the cpu affinity of a thread. + * @param task The thread to change the cpu affinity of + * @param cpu_affinity is a bit mask with the cpu this thread should be bound. + * The bit 0 is the cpu 0, the bit 1, the cpu 1 and so on. + * For example ((1 << 0) | (1 << 1)) will bound to cpu 0 and 1. + * @return 0 if the cpu affinity could be set. + */ + int rtos_task_set_cpu_affinity(RTOS_TASK * task,unsigned cpu_affinity); + + /** + * Return the cpu affinity of a thread. + * @param task The thread to get the cpu affinity + * @return the cpu affinity (@see rtos_task_set_cpu_affinity) + */ + unsigned rtos_task_get_cpu_affinity(const RTOS_TASK * task); + /** * Returns the name by which a task is known in the RTOS. * @param task The task to query. diff --git a/rtt/os/gnulinux/fosi_internal.cpp b/rtt/os/gnulinux/fosi_internal.cpp index 049824c7a..5bb9c2444 100644 --- a/rtt/os/gnulinux/fosi_internal.cpp +++ b/rtt/os/gnulinux/fosi_internal.cpp @@ -77,6 +77,7 @@ namespace RTT INTERNAL_QUAL int rtos_task_create(RTOS_TASK* task, int priority, + unsigned cpu_affinity, const char * name, int sched_type, size_t stack_size, @@ -123,6 +124,9 @@ namespace RTT rv = pthread_create(&(task->thread), &(task->attr), start_routine, obj); log(Debug) <<"Created Posix thread "<< task->thread <thread != 0) { + cpu_set_t cs; + CPU_ZERO(&cs); + for(unsigned i = 0; i < sizeof(cpu_affinity); i++) + { + if(cpu_affinity & (1 << i)) { CPU_SET(i, &cs); } + } + return pthread_setaffinity_np(task->thread, sizeof(cs), &cs); + } + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + if( task && task->thread != 0) { + unsigned cpu_affinity = 0; + cpu_set_t cs; + pthread_getaffinity_np(task->thread, sizeof(cs), &cs); + for(unsigned i = 0; i < sizeof(cpu_affinity); i++) + { + if(CPU_ISSET(i, &cs)) { cpu_affinity |= (1 << i); } + } + return cpu_affinity; + } + return ~0; + } + INTERNAL_QUAL const char * rtos_task_get_name(const RTOS_TASK* task) { return task->name; diff --git a/rtt/os/lxrt/fosi_internal.cpp b/rtt/os/lxrt/fosi_internal.cpp index 497bbbcd2..7f81b95d8 100644 --- a/rtt/os/lxrt/fosi_internal.cpp +++ b/rtt/os/lxrt/fosi_internal.cpp @@ -190,6 +190,7 @@ namespace RTT INTERNAL_QUAL int rtos_task_create(RTOS_TASK* task, int priority, + unsigned cpu_affinity, const char* name, int sched_type, size_t stack_size, @@ -384,6 +385,15 @@ namespace RTT return t->priority; } + INTERNAL_QUAL int rtos_task_set_cpu_affinity(RTOS_TASK * task, unsigned cpu_affinity) + { + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + return ~0; + } } } #undef INTERNAL_QUAL diff --git a/rtt/os/macosx/fosi_internal.cpp b/rtt/os/macosx/fosi_internal.cpp index e29f9c1eb..5618637d2 100644 --- a/rtt/os/macosx/fosi_internal.cpp +++ b/rtt/os/macosx/fosi_internal.cpp @@ -68,6 +68,7 @@ namespace RTT INTERNAL_QUAL int rtos_task_create(RTOS_TASK* task, int priority, + unsigned cpu_affinity, const char * name, int sched_type, size_t stack_size, @@ -263,6 +264,16 @@ namespace RTT return param.sched_priority; } + INTERNAL_QUAL int rtos_task_set_cpu_affinity(RTOS_TASK * task, unsigned cpu_affinity) + { + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + return ~0; + } + INTERNAL_QUAL const char * rtos_task_get_name(const RTOS_TASK* task) { return task->name; diff --git a/rtt/os/win32/fosi_internal.cpp b/rtt/os/win32/fosi_internal.cpp index d30710b50..45e79aae9 100644 --- a/rtt/os/win32/fosi_internal.cpp +++ b/rtt/os/win32/fosi_internal.cpp @@ -137,6 +137,7 @@ void ErrorHandler(LPTSTR lpszFunction) INTERNAL_QUAL int rtos_task_create(RTOS_TASK* task, int priority, const char * name, + unsigned cpu_affinity, int sched_type, size_t stack_size, void * (*start_routine)(void *), @@ -325,6 +326,16 @@ void ErrorHandler(LPTSTR lpszFunction) return GetThreadPriority(t->handle); } + INTERNAL_QUAL int rtos_task_set_cpu_affinity(RTOS_TASK * task, unsigned cpu_affinity) + { + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + return ~0; + } + INTERNAL_QUAL const char * rtos_task_get_name(const RTOS_TASK* t) { /* printf("Get Name: "); diff --git a/rtt/os/xenomai/fosi_internal.cpp b/rtt/os/xenomai/fosi_internal.cpp index 734906134..249dc5043 100644 --- a/rtt/os/xenomai/fosi_internal.cpp +++ b/rtt/os/xenomai/fosi_internal.cpp @@ -196,6 +196,7 @@ namespace RTT INTERNAL_QUAL int rtos_task_create(RTOS_TASK* task, int priority, + unsigned cpu_affinity, const char* name, int sched_type, size_t stack_size, @@ -382,6 +383,16 @@ namespace RTT return 0; } + INTERNAL_QUAL int rtos_task_set_cpu_affinity(RTOS_TASK * task, unsigned cpu_affinity) + { + return -1; + } + + INTERNAL_QUAL unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task) + { + return ~0; + } + INTERNAL_QUAL const char* rtos_task_get_name(const RTOS_TASK* mytask) { return mytask->name; }