Use config variable to set IOTask thread policy
This commit is contained in:
parent
dcd79f3135
commit
d089f38481
@ -223,6 +223,7 @@ CONFIG_VARIABLE (bool, allow_special_bus_removal, "allow-special-bus-removal", f
|
||||
CONFIG_VARIABLE (int32_t, processor_usage, "processor-usage", -1)
|
||||
CONFIG_VARIABLE (int32_t, cpu_dma_latency, "cpu-dma-latency", -1) /* >=0 to enable */
|
||||
CONFIG_VARIABLE (int32_t, io_thread_count, "io-thread-count", -2)
|
||||
CONFIG_VARIABLE (int32_t, io_thread_policy, "io-thread-policy", 0)
|
||||
CONFIG_VARIABLE (gain_t, max_gain, "max-gain", 2.0) /* +6.0dB */
|
||||
CONFIG_VARIABLE (uint32_t, max_recent_sessions, "max-recent-sessions", 10)
|
||||
CONFIG_VARIABLE (uint32_t, max_recent_templates, "max-recent-templates", 10)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "ardour/disk_reader.h"
|
||||
#include "ardour/io_tasklist.h"
|
||||
#include "ardour/process_thread.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/session_event.h"
|
||||
|
||||
#include "pbd/i18n.h"
|
||||
@ -50,54 +51,41 @@ IOTaskList::IOTaskList (uint32_t n_threads)
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_attr_t attr;
|
||||
struct sched_param parm;
|
||||
bool use_rt;
|
||||
int policy;
|
||||
|
||||
pthread_attr_init (&attr);
|
||||
|
||||
bool use_sched_param = true;
|
||||
int policy = SCHED_RR;
|
||||
|
||||
const char* p = getenv ("ARDOUR_IO_SCHED");
|
||||
if (p) {
|
||||
int pi = atoi (p);
|
||||
if (pi < 0) {
|
||||
policy = SCHED_RR;
|
||||
} else if (pi > 0) {
|
||||
switch (Config->get_io_thread_policy ()) {
|
||||
case 1:
|
||||
use_rt = true;
|
||||
policy = SCHED_FIFO;
|
||||
} else {
|
||||
use_sched_param = false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
use_rt = true;
|
||||
policy = SCHED_RR;
|
||||
default:
|
||||
use_rt = false;
|
||||
policy = SCHED_OTHER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (use_sched_param) {
|
||||
parm.sched_priority = pbd_absolute_rt_priority (SCHED_RR, pbd_pthread_priority (THREAD_IO));
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
pthread_attr_setschedpolicy (&attr, SCHED_OTHER);
|
||||
#else
|
||||
pthread_attr_setschedpolicy (&attr, policy);
|
||||
policy = SCHED_OTHER;
|
||||
#endif
|
||||
pthread_attr_setschedparam (&attr, &parm);
|
||||
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
|
||||
pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
DEBUG_TRACE (PBD::DEBUG::IOTaskList, string_compose ("IOTaskList starting %1 threads with priority = %2, policy = %3\n", _n_threads, parm.sched_priority, policy));
|
||||
} else {
|
||||
DEBUG_TRACE (PBD::DEBUG::IOTaskList, string_compose ("IOTaskList starting %1 threads with default priority.\n", _n_threads));
|
||||
}
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::IOTaskList, string_compose ("IOTaskList starting %1 threads with sched policy = %2\n", _n_threads, policy));
|
||||
|
||||
_workers.resize (_n_threads);
|
||||
for (uint32_t i = 0; i < _n_threads; ++i) {
|
||||
if (pthread_create (&_workers[i], &attr, &_worker_thread, this)) {
|
||||
if (pthread_create (&_workers[i], NULL, &_worker_thread, this)) {
|
||||
if (!use_rt || pbd_realtime_pthread_create (policy, THREAD_IO, 0, &_workers[i], &_worker_thread, this)) {
|
||||
if (use_rt && i == 0) {
|
||||
PBD::warning << _("IOTaskList: cannot acquire realtime permissions.") << endmsg;
|
||||
}
|
||||
if (pbd_pthread_create (0, &_workers[i], &_worker_thread, this)) {
|
||||
std::cerr << "Failed to start IOTaskList thread\n";
|
||||
throw failed_constructor ();
|
||||
}
|
||||
if (i == 0) {
|
||||
PBD::warning << _("IOTaskList: cannot acquire realtime permissions.") << endmsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_attr_destroy (&attr);
|
||||
}
|
||||
|
||||
IOTaskList::~IOTaskList ()
|
||||
|
Loading…
Reference in New Issue
Block a user