I'm trying to set the CPU affinity of threads on Linux. I'd like to know which one of the following approaches is recommended:
Get thread id using pthread_self()
Set CPU affinity using pthread_setaffinity_np(....) by passing the thread id as an argument
Get thread id using the gettid() call
Set CPU affinity using sched_setaffinity(....) by passing the thread id in the place of the process id
P.S: After setting the CPU affinity, I intend to increase the scheduling priority of the thread.