When you call pthread_attr_setschedpolicy
, you're requesting that a specific scheduling policy should be set (http://man7.org/linux/man-pages/man3/pthread_attr_setschedpolicy.3.html). The policy you're setting, SCHED_FIFO
, is a real-time policy according to http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. Setting the scheduling policy to a real-time policy requires the CAP_SYS_NICE
capability according to http://man7.org/linux/man-pages/man7/capabilities.7.html. Therefore, the pthread_attr_setschedpolicy
call will fail unless you have that capability.
To solve the problem, either drop the scheduler attribute (and live with the default scheduling), or ensure that your process is started with the correct capabilities (e.g. by starting it as root and dropping all privileges except for CAP_SYS_NICE
).