Can't create pthread due to: Operation not permitted
I upgraded from RHEL 7 to RHEL 8.
These code runs fine on rhel 7 but failed on 8.
int rv = pthread_create(&m_tid, rmcAttr, threadProxy, &launch);
if (0 != rv)
{
throw APP_EXC(SystemCallError,
"Can't create pthread due to: %s",
strerror(errno));
}
When the code runs on rhel 8, The pthread_create returns error code 1 with strerror information below.
" Detail: Can't create pthread due to: Operation not permitted "
error code 1 [EPERM] means the caller does not have appropriate permission to set the required scheduling parameters or scheduling policy".
pthread_attr_t attributes are set as
Detach state = PTHREAD_CREATE_JOINABLE
Scope = PTHREAD_SCOPE_SYSTEM
Inherit scheduler = PTHREAD_EXPLICIT_SCHED
Scheduling policy = SCHED_FIFO
Scheduling priority = 25
It also failed when I set to SCHED_RR or SCHED_OTHER.
Note that I have a root privilege/permission user account.
if I set sched_rt_runtime_us=-1 the code would run fine.
sysctl -w kernel.sched_rt_runtime_us=-1
Setting the value to -1 means that real-time tasks may use up to 100% of CPU times that I should not set per this link.
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/real_time_throttling .
Does anyone knows why I got the "Operation not permitted " on RHEL 8 and how to fix it without setting sched_rt_runtime_us=-1 ?
Thanks for reading it.
-Tom
Responses