Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c864293 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Raise alarm callback thread priority

Since alarms [/callbacks] are used in the critical audio path, raising
the thread priority is required to ensure timely encoding/transmission
of audio packets and avoiding thread pre-emption.

This patch indiscriminatly raises the (single) callback thread priority,
affecting all alarm callbacks. In the future, thread priotiry should be
adjusted based on the alarms pending in the queue.

Bug: 24570959
Change-Id: I64928fd7325f1d6f76815a185dbccf1e01ae30d2
parent 65587bcf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -35,6 +35,13 @@
#include "osi/include/semaphore.h"
#include "osi/include/thread.h"

// Make callbacks run at high thread priority. Some callbacks are used for audio
// related timer tasks as well as re-transmissions etc. Since we at this point
// cannot differentiate what callback we are dealing with, assume high priority
// for now.
// TODO(eisenbach): Determine correct thread priority (from parent?/per alarm?)
static const int CALLBACK_THREAD_PRIORITY_HIGH = -19;

struct alarm_t {
  // The lock is held while the callback for this alarm is being executed.
  // It allows us to release the coarse-grained monitor lock while a potentially
@@ -241,6 +248,7 @@ static bool lazy_initialize(void) {
    return false;
  }

  thread_set_priority(callback_thread, CALLBACK_THREAD_PRIORITY_HIGH);
  thread_post(callback_thread, callback_dispatch, NULL);
  return true;
}