I am learning about the CFS in Linux. So i decided to see how the nice value can give a lower priority for background (i.e. nice) processes.
I ran two CPU processes:
taskset 01 python3 loop.py in two terminals. Then i
renice -n 19 -p 12954 for one of the processes.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 12963 garyF 20 0 29620 9248 5256 R 49.8 0.1 2:05.64 python3 12954 garyF 39 19 29620 9420 5428 R 50.2 0.1 2:12.68 python3
But even though the nice values are different, top says that the processes are getting equal share (50%) of the CPU. Even running these processes for about five minutes, the TIME+ column shows similar cpu time for each. I would expect that the time slice of the nice process is much lower than the normal process, and thus get a lower CPU share. Am i missing something?
This is my
#!/bin/python3 from datetime import datetime; from datetime import timedelta; import signal; import sys; def sigint_handler(signal, frame): dt = datetime.now() - start_time; ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds/1000.0; print('You pressed Ctrl+C!'); print('Time elapsed is ', end='') print(ms, end=''); print('ms.'); sys.exit(0); pass; signal.signal(signal.SIGINT, sigint_handler); start_time = datetime.now(); val = 3; while True: val %= 2; val += 2; pass;