Is nice command a myth?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Is nice command a myth?
# 1  
Old 07-14-2009
Is nice command a myth?

Hello,

Some guy said to me that using the nice command to decrease the priority of a process is a myth, that the operating system corrects the priorities as the processes need cpu. Is this true?
# 2  
Old 07-14-2009
nice changes base priority. Unless you are superuser, it only decreases your priority relative to other processes on the system.

Note: Priority numbers are backwards, higher priority number == lower priority

The OS scheduler can change (up or down) priority. However if your base priority is lower than everyone else logged on, a temporary boost will still have you below the "crowd". ALL non-realtime processes can have process priority changed for a lot of reasons. This is normal.

No way is nice a "myth".
# 3  
Old 07-14-2009
Jim is absolutely correct. Additionally keep in mind that priorities are relative numbers. There are only so many CPU ticks to distribute among processes and if every process has a high priority then every one might get the same amount as if every process has a low priority, as far as these priorities are equal.

I hope this helps.

bakunin
# 4  
Old 07-14-2009
Quote:
that the operating system corrects the priorities as the processes need cpu
Actually, this is true, but nice priorities still come into play. The longer a process has been running and consuming CPU resources, the lower a priority it gets. The more time it's been in the run queue without having had a chance to execute, the higher priority it gets. These mechanisms are meant to ensure fairness and reduce "starvation". Nice affects starting priorities, and only after a very long runtime, will the nice level for a particular process become irrelevant.

At any rate, task scheduling is OS-dependent. The Linux 2.6 kernel uses something called the Completely Fair Scheduler. From the author, this quote might be relevant:
Quote:
the CFS scheduler has a much stronger handling of nice levels and SCHED_BATCH: both types of workloads should be isolated much more agressively than under the vanilla [ie, than the standard Linux scheduler] scheduler.
# 5  
Old 07-14-2009
The nice command breaks ties between processes that would otherwise be treated identically by the kernel. And it only effects processes while they are cpu bound. If a process is waiting for I/O to complete, it must wait regardless of how little niceness it has.

But I am a little tempted to rewrite readline to check the nice value. If the process has negative niceness, it would wait 5 seconds then issue a hurry-up message.... "Hey! Let's speed it up! I don't have all day!" Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wall command with nice text formatting

with using wall command, how can i have a carriage return in my broadcast message. i try to broadcast from a file, i were to use "cat myfile | wall" for broadcasting. but when the message broadcast somehow the format run away. this the text in my file: line 1 line 2 line 3 when broadcast ... (3 Replies)
Discussion started by: lsy
3 Replies

2. BSD

Very high nice percentage in top command

Hello Folks, Recently our FreeBSD 7.1 i386 system became very sluggish. Nothing much is happening over there & whatever is running takes eternity to complete. All the troubleshooting hinted towards a very high nice percentage. Can that be the culprit? Pasting snippets of top command,... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

3. Shell Programming and Scripting

How to use nice command?

Dear Friends, I have a directory when i take du of that directory it takes alot of memory and cpu and I/O, i want to use nice to run my script that have du command slowly so it won't take I/O and cpu, please suggest. (6 Replies)
Discussion started by: learnbash
6 Replies

4. Shell Programming and Scripting

Call Nice command (priority) from /bin/ksh

Hello, I am just starting with shell scripting, as everyone will soon see from my question. What I'm trying to do is call the Nice command to set the script process priority from /bin/ksh. The difference is I'm running it not directly through the shell, but through Bigfix (very similar to... (3 Replies)
Discussion started by: solly119
3 Replies

5. UNIX for Dummies Questions & Answers

The nice command

hello everybody: I have some job running on tru64 system and Im the root, due to limited resources I end up with my job ( vdump) for example taking the lowest share, I researched the nice command on the net, but couldnt get enough info, can I use it to already running process or I only use it... (1 Reply)
Discussion started by: aladdin
1 Replies

6. Programming

nice command and nice() system call

Hi I want to implement the nice command in the shell that I am building. I came to know that there is a corresponding nice() system call for the same. But since I will be forking different processes to run different commands typed on the command prompt, is there any way I can make a command... (2 Replies)
Discussion started by: tejbuch
2 Replies

7. UNIX for Dummies Questions & Answers

is ‘nice’ command useful on a multi-CPU UNIX system?

Can someone tell me this. thanks (1 Reply)
Discussion started by: xoxouu
1 Replies

8. UNIX for Advanced & Expert Users

process nice level command line vs cron

Under, Solaris 10 I have the following problem: A script executed at command line runs with nice level 0, as expected. Same script started under (user) crontab runs with nice level 2. I would prefer it run at 0. Is this possible? If so, how? Thanks. (0 Replies)
Discussion started by: henrydark
0 Replies

9. UNIX for Dummies Questions & Answers

nice (user command)

Can someone tell me .. how to find a user & process who has executed nice (scheduled priority) to one of his process. .Tks.. (5 Replies)
Discussion started by: sivan
5 Replies
Login or Register to Ask a Question