All pastes #477131 Raw Edit

tmorton

public cpp v1 · immutable
·published 2007-05-08 14:13 UTC
rendered paste body
#if defined (Q_WS_X11)int* (*setaffinity_func)(pid_t,unsigned int,cpu_set_t *);#endifvoid AudioDeviceThread::run_on_cpu( int cpu ){#if defined (Q_WS_X11)		void *setaffinity_handle = dlopen(NULL, RTLD_LAZY); //this may not be portable to platforms other than linux - tajmorton@gmail.com	//void (*setaffinity_func) = dlsym(setaffinity_handle, "sched_setaffinity");	setaffinity_func = dlsym(setaffinity_handle, "sched_setaffinity");	if (setaffinity_func != NULL) {		cpu_set_t mask;		CPU_ZERO(&mask);		CPU_SET(cpu, &mask);		if ((*setaffinity_func)(0, sizeof(mask), &mask)) {			PWARN("Unable to set CPU affinity");		} else {			PMESG("Running AudioDeviceThread on CPU %d", cpu);		}	}#endif}