I use python to write a simple python program to set quota for a thread.
# make path
path = "/sys/fs/cgroup/cpu/%d" % (tid)
os.mkdir(path)
# to set
set_quota = "echo %d > /sys/fs/cgroup/cpu/%d/cpu.cfs_quota_us" % (quota_us, tid)
os.system(set_quota)
set_quota = "echo %d > /sys/fs/cgroup/cpu/%d/tasks" % (tid, tid)
os.system(set_quota)
# to close
set_quota = "echo %d > /sys/fs/cgroup/cpu/%d/cpu.cfs_quota_us" % (-1, tid)
os.system(set_quota)
set_quota = "echo %d > /sys/fs/cgroup/cpu/%d/tasks" % (tid, tid)
os.system(set_quota)
I am sure that the tid exists but it appears when I start run this program so I need to make a path for it explicitly. But I get an error about sh: echo: I/O error
. Why is it and how to solve it?
Note: the I/O error occurs after echo > /sys/fs/cgroup/cpu//cpu.cfs_quota_us