Skip to content
Browse files

One attempt at fixing #486: temporarily elevate the priority of the A…

  • Loading branch information
giuliomoro committed Sep 8, 2018
1 parent b82e079 commit 6b05171797f5df545a0fa61bf791742c01ed8816
Showing with 30 additions and 1 deletion.
  1. +30 −1 core/AuxiliaryTasks.cpp
@@ -118,6 +118,35 @@ int Bela_scheduleAuxiliaryTask(AuxiliaryTask task)
return 0;
#ifdef XENOMAI_SKIN_posix
// the task has not yet had a chance to run.
// let's enforce it now. This will block the current thread
// until the other starts.
struct sched_param param;
int policy;
int ret = __wrap_pthread_getschedparam(taskToSchedule->task,
&policy, &param);
// set the priority to maximum
int originalPriority = param.sched_priority;
param.sched_priority = __wrap_sched_get_priority_max(SCHED_FIFO);
SCHED_FIFO, &param);
// just in case we have the same priority, let the
// other go first
fprintf(stderr, "Didn't work\n");
// by the time we are here, the other thread has run, set the
// started flag, and is now waiting for the cond
// So, restore its schedparams
param.sched_priority = originalPriority;
policy, &param);
if(int ret = __wrap_pthread_mutex_trylock(&taskToSchedule->mutex))
// If we cannot get the lock, then the task is probably still running.
@@ -137,6 +166,7 @@ static void suspendCurrentTask(InternalAuxiliaryTask* task)
#ifdef XENOMAI_SKIN_posix
task->started = true;
__wrap_pthread_cond_wait(&task->cond, &task->mutex);
@@ -191,7 +221,6 @@ int Bela_startAuxiliaryTask(AuxiliaryTask task){
// The task has already been started upon creation.
// It is currently waiting on a condition variable.
taskStruct->started = true;
return 0;

0 comments on commit 6b05171

Please sign in to comment.
You can’t perform that action at this time.