I'm using ffmpeg in my application which internally spawns lots of threads. However, I would like that my application which has real-time semantics has one of the cpu cores for itself. So basically I need a way to disable scheduling of ffmpeg spawned threads to a core and set the affinity of my main thread to that core.
Is this possible?
e.g.
main()
{
struct sched_param param;
param.sched_priority = 95;
sched_setscheduler(getpid(), SCHED_FIFO, ¶m);
int core_id = 0;
// TODO: Remove core_id from cpuset for all future thread default affinities.
pthread_t ffmpeg_thread;
pthread_create(&ffmpeg_thread, NULL, run_ffmpeg, NULL);
pthread_t rt_thread;
pthread_create(&rt_thread, NULL, run_rt, NULL);
cpu_set_t rt_cpuset;
CPU_ZERO(&rt_cpuset);
CPU_SET(core_id, &rt_cpuset);
pthread_setaffinity_np(rt_thread, sizeof(rt_cpuset), &rt_cpuset);
pthread_join(ffmpeg_thread, NULL);
pthread_join(rt_threadm, NULL);
}