LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 11-12-2012, 01:38 PM   #1
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
Process nice value, priority


How can any of these be the answer when all the choices use nice -n and the man page says for -n?

Quote:
-n, --adjustment=N
add integer N to the niceness (default 10)
Attached Thumbnails
Click image for larger version

Name:	priority_nice_difference.JPG
Views:	24
Size:	59.7 KB
ID:	11218  
 
Old 11-12-2012, 01:46 PM   #2
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Original Poster
Rep: Reputation: 85
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?
 
Old 11-12-2012, 03:08 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 11-12-2012, 03:19 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 11-12-2012, 04:17 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
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.
 
Old 11-12-2012, 04:18 PM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
See also "renice"
 
Old 11-13-2012, 03:24 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Merged your dupe/closely related threads. Please refrain from multi-posting.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing priority using nice() zak100 Programming 2 10-12-2010 05:39 AM
Nice level set but process gets wrong priority akring Linux - Kernel 3 11-03-2008 09:20 AM
Nice level set but process gets wrong priority akring Linux - General 7 10-29-2008 04:25 AM
"ps" does not give nice value of process if realtime priority set... CJS Linux - General 1 07-16-2008 09:23 PM
process priority,nice -- small question regarding high/low priority values beeblequix Linux - Newbie 1 10-11-2006 10:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration