@@ -81,15 +81,18 @@ struct RtaiApp : RtapiApp {
8181 static void *wrapper (void *arg) {
8282 auto task = reinterpret_cast <RtaiTask*>(arg);
8383 pthread_setspecific (key, arg);
84- task->rt_task = rt_task_init (task->id , task->prio , 0 , 0 );
85- rt_set_periodic_mode ();
86- start_rt_timer (nano2count (task->period ));
87- if (task->uses_fp ) rt_task_use_fpu (task->rt_task , 1 );
84+
85+ int nprocs = sysconf ( _SC_NPROCESSORS_ONLN );
86+ int cpus_allowed = 1 << (nprocs-1 ); // Use last CPU as default
8887 const static int rt_cpu_number = find_rt_cpu_number ();
8988 if (rt_cpu_number != -1 ) {
9089 rtapi_print_msg (RTAPI_MSG_INFO, " rt_cpu_number = %i\n " , rt_cpu_number);
91- rt_set_runnable_on_cpus (task-> rt_task , 1u << rt_cpu_number) ;
90+ cpus_allowed = 1 << rt_cpu_number;
9291 }
92+ task->rt_task = rt_task_init_schmod (task->id , task->prio , 0 , 0 , SCHED_FIFO, cpus_allowed);
93+ rt_set_periodic_mode ();
94+ start_rt_timer (nano2count (task->period ));
95+ if (task->uses_fp ) rt_task_use_fpu (task->rt_task , 1 );
9396 rt_make_hard_real_time ();
9497 rt_task_make_periodic_relative_ns (task->rt_task , task->period , task->period );
9598 (task->taskcode ) (task->arg );
0 commit comments