Results 1 to 2 of 2
Hey guys, I'm working on an Embedded Linux kernel 188.8.131.52. This machine runs a main utility that interacts with the kernel. Let's call this utility MainUtility . I wrote a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-31-2012 #1
- Join Date
- Oct 2011
nice() is not nice to my app..
I'm working on an Embedded Linux kernel 184.108.40.206.
This machine runs a main utility that interacts with the kernel. Let's call this utility MainUtility.
I wrote a TestUtilty that runs for 5 seconds and increments a variable X in a loop. After 5 seconds the TestUtility displays X's value and dye.
I execute the TestUtility with different nice values while the MainUtility is running and while the MainUtility is not running.
I do not understand my findings. I hope someone here could shed some light on the matter.
(*) Please note, I did every test 100 times, and the result was consistent.
A) When the MainUtility is not running if I execute the TestUtility with nice=0,nice=-20 and nice=20 I get the following result:
nice = 0 after 5 seconds X~=1,553,500
nice = -20 after 5 seconds X~=1,345,000
nice = 20 after 5 seconds X~=1,553,500
It's strange. Shouldn't nice=-20 gets the best results?
Can someone explain why did the opposite occur?
B) When I execute the TestUtility while the MainUtility is running, with nice=0,nice=-20 and nice=20 I get the following result:
nice = 0 after 5 seconds X~=1,000,000
nice = -20 after 5 seconds X~=1,000,000
nice = 20 after 5 seconds X~=1,000,000
Can someone explain how come the nice has no effect??
Thanks from advance!
- 08-01-2012 #2
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
It depends upon the scheduler the kernel is using. A lot of embedded systems use the "real-time" scheduler, so I'm not sure what effect that nice has upon them. In any case, nice with a large negative number (like -20) will only suggest to the kernel that your application gets priority scheduling when other applications need to run that have a higher niceness factor. It still doesn't affect I/O and other kernel operations.
If you need deterministic performance behavior, and absolute priority enforcement (and no I/O priority inversions), then you will need to move to a true real-time operating system such as QNX.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!