Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Original Poster
Rep:
More questions about a process's niceness
man nice says
Quote:
-n, --adjustment=N
add integer N to the niceness (default 10)
1) So I tested this by running nice -n 3 top. top got a nice value of 3, but shouldn't it be 13 since it's adding? default is 10 + 3 (I added).
2) Also if the default is 10, then why does top get a nice value of 0, when I run it without the nice command?
The man page also says
Quote:
DESCRIPTION
Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Nicenesses range from -20 (most favorable scheduling) to 19 (least favorable).
3) So I run nice with no arguments, and I get 0. Shouldn't it be 10 sense the man page says the default nice value is 10?
4) When running nice with no arguments by itself, does the number given mean that is the nice value of the current shell it's being ran in (such as bash), the nice value that will be given to processes launched from that shell, or something different?
The default value of the adjustment is 10, i.e., the amount that is added to the niceness of the current process. When you run "nice -n 3 top", the adjustment of 3 is added to the niceness inherited from your shell, probably running with a niceness of 0, and the result is 3. When you run a process via nice and do not specify an adjustment, you get an adjustment of 10. Running nice with no arguments at all is a special case where the current value is reported and there is no adjustment at all.
Scheduling priority is not the same thing as niceness. The scheduling priority is the sum of the niceness and a base priority calculated from CPU usage and other factors.
The scheduler considers many factors, of which "niceness" is only one. This parameter in-effect allows you to contribute your personal opinion about what the scheduler ought to do with this process. It's a very important input since it represents something that the computer would have no way to determine on its own, as well as something that is from your point-of-view.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.