Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brbubba

macrumors 6502
Original poster
May 20, 2006
485
0
Could someone please explain to me, in laymen's terms what "nice" is. I am looking at my CPU activity monitor and it is saying around 30% is being used by "Nice." I looked it up in help and this is what I got, "For more information on "nice" processes, see the man page. Open Terminal, located in Applications/Utilities, and enter "man nice"."

So I opened a terminal and looked at the man page and this is what I got,

NAME
nice -- execute a utility with an altered scheduling priority

SYNOPSIS
nice [-n increment] utility [argument ...]

DESCRIPTION
nice runs utility at an altered scheduling priority. If an increment is
given, it is used; otherwise an increment of 10 is assumed. The super-
user can run utilities with priorities higher than normal by using a neg-
ative increment. The priority can be adjusted over a range of -20 (the
highest) to 20 (the lowest).

Needless to say, help wasn't much help at all.
 
As is my understanding, the nice command is a way to make programs use more or less CPU time. It would be useful if you have a processor intensive program, but dont want it to hog all the processor.
 
The 'nice' tool is used to run programs with different execution priorities.

A 'niced' program can run with a higher or lower cpu priority than normal, for example, background processes can be set not to take over your CPU by giving them a positive nice value, and programs that are more important (such as DVD burning software), can be given CPU priority by giving them negative nice values.
 
"Nice" is pleasant; agreeable; satisfactory or fine; subtle as in 'the gentleman was nice to my mom' or 'a nice distinction' Duh! :)


In computer terminology, "nice" is pronounced "niece", so that helps to distinguish the word from the first definition. The nice command allows you to reduce CPU cycles to a particular app (thread).

In Terminal, type: renice +20 [pid]
where pid is the process id number; the number OSX assigns to each running app. You can usually find the number by typing top in Terminal or open Activity Monitor.

Plus+ numbers (+1 to +20) reduce CPU priority, accordingly. So a pid of +20 is given less CPU time than a pid of +1. It also goes in reverse down to -20 (which means the app is given the highest CPU priority) You need to be logged into Super User mode to lower pid numbers.
 
Ok I think I am getting more confused. I understand computers very well on a macroscopic level, and don't understand them at all on a microscopic level, or in this case programming and code execution. Nor do I ever care to...

Maybe we should break this down. Ok so % User I assume is user run applications and how much CPU they take up. % System I assume is the cpu thats being used for system processes. And % Idle is CPU not in use. So what the heck is % Nice? If 40% of the cpu is in use for Nice, what is it doing? Why is Nice taking up that much CPU?
 
The 'nice' tool is used to run programs with different execution priorities.

A 'niced' program can run with a higher or lower cpu priority than normal, for example, background processes can be set not to take over your CPU by giving them a positive nice value, and programs that are more important (such as DVD burning software), can be given CPU priority by giving them negative nice values.

That's probably not the greatest example, because DVD burning software is going to utilize threads which operate in the Real-Time priority band. Provided the software was written with this in mind, altering its 'nice' value won't affect the burn.

There are four priority bands used by the Mach scheduler (in increasing order of priority): Normal, System High, Kernel, and Real-Time.

Normal applications run in either Normal or System High priority. These are the applications you can use nice(1) or renice(8) on to change their priority. Obviously, applications which are given System High priority will have the privilege of being considered first when it comes time to schedule jobs on the CPU; they still have to take a back seat to Kernel and Real-Time jobs.

Kernel priority is reserved for threads which run inside of the Kernel. Things like I/O drivers for external devices run with Kernel priority.

Real-Time priority is just like it sounds: jobs that run in real-time are guaranteed to have time on the processor within a certain timeframe (as long as its request is reasonbly sane). If your software needs to run for 3000 cycles during the next 7000 cycles, real-time priority will try to make this possible sacrificing Normal, System High, and even Kernel priority jobs to do it. Burning a CD or DVD is a good example of a job that needs to have Real-Time priority. The laser burning the disc cannot be stopped in the middle of a burn; if your application doesn't feed data to the drive in a timely manner the burn will be corrupted. Audio playback is another real-time application.
 
I think it's worth pointing out that "nice" is more useful in a multi-user environment than on a single-user box. It can help keep one person's long, cpu-intensive task from adversely impacting other users' jobs (well, too much anyway).
 
Ok I think I am getting more confused. I understand computers very well on a macroscopic level, and don't understand them at all on a microscopic level, or in this case programming and code execution. Nor do I ever care to...

Maybe we should break this down. Ok so % User I assume is user run applications and how much CPU they take up. % System I assume is the cpu thats being used for system processes. And % Idle is CPU not in use. So what the heck is % Nice? If 40% of the cpu is in use for Nice, what is it doing? Why is Nice taking up that much CPU?

You can think of User and Nice as the same thing, so the amount of resources used do not change. What changes is the way this impacts other system activities.

If you run a process that use, say, 100% of your cpu will leave no spare resources available, so if you launch another process that uses up 100% as well they both will contend for the available resources so each process will slow down the other one and they both will run at half speed.
'Nice' cpu time on the other hand is allocated only if available, so in the same example, if you run a niced process that consumes 100% of cpu resources and then a 'user' process that uses the same 100% this second process won't be slowed down.

You could sum it all up by saying that user/system cpu time slows down your machine if you want to do something else at the same time, while nice cpu time doesn't.

This is a broad generalization. Also remember that cpu time is accounted by cpu, so if your system is dual core you have a total of 200% to spend, or 400% on a quad core.
 
I have never ever heard anyone pronounce "nice" in this way; and I've been working alongside Unix admins for lots o' years now. I think someone's been yankin' your chain. :D

Nice rhymes with ice.

I have to agree with this statement. I have never heard, nor have I ever uttered "nice" in any other way than expected. Either that, or there's been a lot of messed up solaris guys working with me. ;)
 
I have to agree with this statement. I have never heard, nor have I ever uttered "nice" in any other way than expected. Either that, or there's been a lot of messed up solaris guys working with me. ;)

Well, "messed up" and "Solaris guys" kind of go hand in hand. :D I kid, I kid...

(although enabling telnet by default in this day and age IS kind of messed up; but that's Sun's fault, not your coworkers)
 
Well, "messed up" and "Solaris guys" kind of go hand in hand. :D I kid, I kid...

(although enabling telnet by default in this day and age IS kind of messed up; but that's Sun's fault, not your coworkers)

Ah telnet.. Last time I used it, it was to connect to a printer.
 
(although enabling telnet by default in this day and age IS kind of messed up; but that's Sun's fault, not your coworkers)

Speak of the devil.. :D

Systems Affected

* Sun Solaris 10 (SunOS 5.10)
* Sun "Nevada" (SunOS 5.11)

Both SPARC and Intel (x86) architectures are affected.


Overview

A worm is exploiting a vulnerability (VU#881872) in the Sun Solaris
telnet daemon (in.telnetd).


I. Description

A worm is exploiting a vulnerability in the telnet daemon
(in.telnetd) on unpatched Sun Solaris systems. The vulnerability
allows the worm (or any attacker) to log in via telnet (23/tcp)
with elevated privileges. Further details about the vulnerability
are available in Vulnerability Note VU#881872 (CVE-2007-0882).

Because VU#881872 is trivial to exploit and sufficient technical
detail is publicly available, any attacker, not just this worm,
could exploit vulnerable systems.

Characteristics of the worm include, but are not limited to:

* Exploiting VU#881872 to log in via telnet as the users adm or lp
* Changing permissions on /var/adm/wtmpx to -rw-r--rw-
* Creating the directory .adm in /var/adm/sa/
* Adding .profile files to /var/adm/ and /var/spool/lp/
* Installing an authenticated backdoor shell on port 32982/tcp
* Modifying crontab entries for the users adm and lp
* Scanning for other hosts running telnet (23/tcp)

Sun has published information about the worm in the Security Sun
Alert Feed including an inoculation script that disables the telnet
daemon and reverses known changes made by the worm.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.