⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch39_09.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<SPANCLASS="link">makefiles (<ACLASS="linkend"HREF="ch28_13.htm"TITLE="make Isn't Just for Programmers! ">28.13</A>)</SPAN>,when you are running the Bourne shell, etc. The principles are the same. <EMCLASS="emphasis">nice</EM> numbers run from -20 to 20, with the default being zero. Only the syntax has been changed to confuse you. For the standalone version, <CODECLASS="literal">-</CODE><EMCLASS="emphasis">n</EM> requestsa positive <EMCLASS="emphasis">nice</EM> number (lower priority) and <CODECLASS="literal">--</CODE><EMCLASS="emphasis">n</EM>requests a negative <EMCLASS="emphasis">nice</EM> number (higher priority-superuser only). Consider these commands:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>nice -6 awk -f proc.awk datafile &gt; awk.out</B></CODE># <CODECLASS="userinput"><B>nice --6 awk -f proc.awk datafile &gt; awk.out</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">The first command runs <EMCLASS="emphasis">awk</EM> with a high <EMCLASS="emphasis">nice</EM> number (i.e.,6). The second command, which can be issued only by a superuser, runs<EMCLASS="emphasis">awk</EM> with a low <EMCLASS="emphasis">nice</EM> number (i.e., -6).  If no level isspecified, the default argument is -10.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-68-SECT-1.0.3">39.9.3 System V C Shell nice </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-44123"></A><ACLASS="indexterm"NAME="AUTOID-44126"></A>System V takes a slightly different view of <EMCLASS="emphasis">nice</EM>numbers. <EMCLASS="emphasis">nice</EM> levels run from 0 to 39; the default is 20. Thenumbers are different but their meanings are the same: 39 correspondsto the lowest possible priority, and 0 is the highest. A few System Vimplementations support real-time submission via <EMCLASS="emphasis">nice</EM>. Jobssubmitted by root with extremely low <EMCLASS="emphasis">nice</EM> numbers (-20 orbelow) allegedly get all of the CPU's time.  Systems on whichthis works properly are very rare and usually advertise support forreal-time processing. In any case, running jobs this way will destroymultiuser performance. This feature is completely different fromreal-time priorities in System V Release 4.</P><PCLASS="para">With these exceptions, the C shell version of <EMCLASS="emphasis">nice</EM> is the same asits BSD cousin. To submit a job at a low priority, use the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>nice <CODECLASS="replaceable"><I>command</I></CODE></B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">This increases the command's niceness by the default amount (4, the same as BSD UNIX); <EMCLASS="emphasis">command</EM> will run at <EMCLASS="emphasis">nice</EM> level 24. To run a job at an arbitrary priority, use one of thefollowing commands:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>nice +</B></CODE><CODECLASS="replaceable"><I>n</I></CODE><CODECLASS="userinput"><B> command</B></CODE>% <CODECLASS="userinput"><B>nice -</B></CODE><CODECLASS="replaceable"><I>n</I></CODE><CODECLASS="userinput"><B> command</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">where <EMCLASS="emphasis">n</EM> is an integer between 0 and 19. The <EMCLASS="emphasis">+n</EM> entryrequests a higher <EMCLASS="emphasis">nice</EM> level (a decreased priority), while <EMCLASS="emphasis">-n</EM>requests a lower <EMCLASS="emphasis">nice</EM> level (a higher priority). Again, this issimilar to BSD UNIX, with one important difference: <EMCLASS="emphasis">n</EM> is nowrelative to the default <EMCLASS="emphasis">nice</EM> level. That is, the command: </P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>nice +6 awk -f proc.awk datafile &gt; awk.out</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">runs <EMCLASS="emphasis">awk</EM> at <EMCLASS="emphasis">nice</EM> level 26.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-68-SECT-1.0.4">39.9.4 System V Standalone nice </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-44166"></A>Once again, the standalone version of <EMCLASS="emphasis">nice</EM> is useful if you arewriting makefiles or shell scripts or if you use the Bourne shell asyour interactive shell. It is similar to the C shell version, withthese differences:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">With no arguments, standalone <EMCLASS="emphasis">nice</EM> increases the <EMCLASS="emphasis">nice</EM> number by 10 instead of by 4; this is a significantly greater reduction in the program's priority.</P></LI><LICLASS="listitem"><PCLASS="para">With the argument <EMCLASS="emphasis">-n</EM>, <EMCLASS="emphasis">nice</EM> increases the <EMCLASS="emphasis">nice</EM> number by <EMCLASS="emphasis">n</EM> (reducing priority).</P></LI><LICLASS="listitem"><PCLASS="para">With the argument <EMCLASS="emphasis">-&nbsp;-n</EM>, <EMCLASS="emphasis">nice</EM> decreases the <EMCLASS="emphasis">nice</EM> number by <EMCLASS="emphasis">n</EM> (increasing priority; superuser only).</P></LI></UL><PCLASS="para">Consider these commands:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>nice -6 awk -f proc.awk datafile &gt; awk.out</B></CODE># <CODECLASS="userinput"><B>nice --6 awk -f proc.awk datafile &gt; awk.out</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">The first command runs <EMCLASS="emphasis">awk</EM> at a higher <EMCLASS="emphasis">nice</EM> level (i.e., 26, which corresponds to a lower priority). The second command, which can be given only by the superuser, runs<EMCLASS="emphasis">awk</EM> at a lower <EMCLASS="emphasis">nice</EM> level (i.e., 14).</P></DIV><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">ML</SPAN> <SPANCLASS="bibliomisc">from O'Reilly &amp; Associates' <CITECLASS="citetitle">System Performance Tuning</CITE>, Chapter 3</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch39_08.htm"TITLE="39.8 A Big Environment Can Slow You Down "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 39.8 A Big Environment Can Slow You Down "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch39_10.htm"TITLE="39.10 A nice Gotcha "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 39.10 A nice Gotcha "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">39.8 A Big Environment Can Slow You Down </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">39.10 A nice Gotcha </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -