EPERM operation not permitted while changing scheduling policy

General support questions
Post Reply
Posts: 21
Joined: 2018/09/20 11:23:09

EPERM operation not permitted while changing scheduling policy

Post by ssharma12 » 2021/01/20 08:09:24

Hi All,

I was trying to change set the new scheduling policy on centos7, Getting EPERM Operation not permitted error.
Please find the below scenario:

This is my python code which is trying to change the priority and setting the new scheduling policy from SCHED_OTHER TO SCHED_RR
On my VM when I'm running this script as a sudo it's working fine, it is able to change the policy.

But when I'm running this script from my centos7.8 Desktop while sched_setscheduler() calling this function getting EPERM error operation not permitted, I'm doing this also as a sudo user.

I got the resolution like when i changed the /proc/sys/kernel/sched_rt_runtime_us from 950000 to -1 its working fine, on VM /proc/sys/kernel/sched_rt_runtime_us=950000 and its working fine.

Can anyone help me here.
#!/usr/bin/env python2.7

import ctypes
import os

SCHED_OTHER = ctypes.c_int(0)
SCHED_FIFO = ctypes.c_int(1)
SCHED_RR = ctypes.c_int(2)

libc = ctypes.CDLL("libc.so.6")
print("Before my scheduler=%d" % libc.sched_getscheduler(os.getpid()))

param = ctypes.c_int(60)
print (os.getpid())
err = libc.sched_setscheduler(os.getpid(), SCHED_RR, ctypes.byref(param))
#err = libc.sched_setscheduler(os.getpid(), SCHED_RR, 0)
print (err)
if err != 0:
print("errno=%d" % ctypes.get_errno())

print("After my scheduler=%d" % (libc.sched_getscheduler(os.getpid())))


Post Reply

Return to “CentOS 7 - General Support”