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

📄 basics-processes.html

📁 FreeBSD安装说明概述 FreeBSD 提供了一个以文字为主
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Processes</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手册" href="index.html" /><link rel="UP" title="UNIX Basics" href="basics.html" /><link rel="PREVIOUS" title="Mounting and Unmounting File Systems"href="mount-unmount.html" /><link rel="NEXT" title="Daemons, Signals, and Killing Processes"href="basics-daemons.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手册</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="mount-unmount.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 3. UNIX Basics</td><td width="10%" align="right" valign="bottom"><a href="basics-daemons.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="BASICS-PROCESSES" name="BASICS-PROCESSES">3.7.Processes</a></h1><p>FreeBSD is a multi-tasking operating system. This means that it seems as though morethan one program is running at once. Each program running at any one time is called a <iclass="FIRSTTERM">process</i>. Every command you run will start at least one new process,and there are a number of system processes that run all the time, keeping the systemfunctional.</p><p>Each process is uniquely identified by a number called a <i class="FIRSTTERM">processID</i>, or <i class="FIRSTTERM">PID</i>, and, like files, each process also has one ownerand group. The owner and group information is used to determine what files and devicesthe process can open, using the file permissions discussed earlier. Most processes alsohave a parent process. The parent process is the process that started them. For example,if you are typing commands to the shell then the shell is a process, and any commands yourun are also processes. Each process you run in this way will have your shell as itsparent process. The exception to this is a special process called <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">init</span>(8)</span>. <ttclass="COMMAND">init</tt> is always the first process, so its PID is always 1. <ttclass="COMMAND">init</tt> is started automatically by the kernel when FreeBSD starts.</p><p>Two commands are particularly useful to see the processes on the system, <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span> and <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">top</span>(1)</span>. The <ttclass="COMMAND">ps</tt> command is used to show a static list of the currently runningprocesses, and can show their PID, how much memory they are using, the command line theywere started with, and so on. The <tt class="COMMAND">top</tt> command displays all therunning processes, and updates the display every few seconds, so that you caninteractively see what your computer is doing.</p><p>By default, <tt class="COMMAND">ps</tt> only shows you the commands that are runningand are owned by you. For example:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">ps</kbd>  PID  TT  STAT      TIME COMMAND  298  p0  Ss     0:01.10 tcsh 7078  p0  S      2:40.88 xemacs mdoc.xsl (xemacs-21.1.14)37393  p0  I      0:03.11 xemacs freebsd.dsl (xemacs-21.1.14)48630  p0  S      2:50.89 /usr/local/lib/netscape-linux/navigator-linux-4.77.bi48730  p0  IW     0:00.00 (dns helper) (navigator-linux-)72210  p0  R+     0:00.00 ps  390  p1  Is     0:01.14 tcsh 7059  p2  Is+    1:36.18 /usr/local/bin/mutt -y 6688  p3  IWs    0:00.00 tcsh10735  p4  IWs    0:00.00 tcsh20256  p5  IWs    0:00.00 tcsh  262  v0  IWs    0:00.00 -tcsh (tcsh)  270  v0  IW+    0:00.00 /bin/sh /usr/X11R6/bin/startx -- -bpp 16  280  v0  IW+    0:00.00 xinit /home/nik/.xinitrc -- -bpp 16  284  v0  IW     0:00.00 /bin/sh /home/nik/.xinitrc  285  v0  S      0:38.45 /usr/X11R6/bin/sawfish</pre><p>As you can see in this example, the output from <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">ps</span>(1)</span> is organized into a number of columns. <varclass="LITERAL">PID</var> is the process ID discussed earlier. PIDs are assigned startingfrom 1, go up to 99999, and wrap around back to the beginning when you run out. The <varclass="LITERAL">TT</var> column shows the tty the program is running on, and can safelybe ignored for the moment. <var class="LITERAL">STAT</var> shows the program's state, andagain, can be safely ignored. <var class="LITERAL">TIME</var> is the amount of time theprogram has been running on the CPU--this is usually not the elapsed time since youstarted the program, as most programs spend a lot of time waiting for things to happenbefore they need to spend time on the CPU. Finally, <var class="LITERAL">COMMAND</var> isthe command line that was used to run the program.</p><p><span class="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span> supports anumber of different options to change the information that is displayed. One of the mostuseful sets is <var class="LITERAL">auxww</var>. <var class="OPTION">a</var> displaysinformation about all the running processes, not just your own. <varclass="OPTION">u</var> displays the username of the process' owner, as well as memoryusage. <var class="OPTION">x</var> displays information about daemon processes, and <varclass="OPTION">ww</var> causes <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">ps</span>(1)</span> to display the full command line, rather thantruncating it once it gets too long to fit on the screen.</p><p>The output from <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">top</span>(1)</span> is similar. A sample session looks likethis:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">top</kbd>last pid: 72257;  load averages:  0.13,  0.09,  0.03    up 0+13:38:33  22:39:1047 processes:  1 running, 46 sleepingCPU states: 12.6% user,  0.0% nice,  7.8% system,  0.0% interrupt, 79.7% idleMem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K FreeSwap: 256M Total, 38M Used, 217M Free, 15% Inuse  PID USERNAME PRI NICE  SIZE    RES STATE    TIME   WCPU    CPU COMMAND72257 nik       28   0  1960K  1044K RUN      0:00 14.86%  1.42% top 7078 nik        2   0 15280K 10960K select   2:54  0.88%  0.88% xemacs-21.1.14  281 nik        2   0 18636K  7112K select   5:36  0.73%  0.73% XF86_SVGA  296 nik        2   0  3240K  1644K select   0:12  0.05%  0.05% xterm48630 nik        2   0 29816K  9148K select   3:18  0.00%  0.00% navigator-linu  175 root       2   0   924K   252K select   1:41  0.00%  0.00% syslogd 7059 nik        2   0  7260K  4644K poll     1:38  0.00%  0.00% mutt...</pre><p>The output is split into two sections. The header (the first five lines) shows the PIDof the last process to run, the system load averages (which are a measure of how busy thesystem is), the system uptime (time since the last reboot) and the current time. Theother figures in the header relate to how many processes are running (47 in this case),how much memory and swap space has been taken up, and how much time the system isspending in different CPU states.</p><p>Below that are a series of columns containing similar information to the output from<span class="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span>. As before youcan see the PID, the username, the amount of CPU time taken, and the command that wasrun. <span class="CITEREFENTRY"><span class="REFENTRYTITLE">top</span>(1)</span> alsodefaults to showing you the amount of memory space taken by the process. This is splitinto two columns, one for total size, and one for resident size--total size is how muchmemory the application has needed, and the resident size is how much it is actually usingat the moment. In this example you can see that <b class="APPLICATION"><spanclass="TRADEMARK">Netscape</span>&reg;</b> has required almost 30&nbsp;MB of RAM, but iscurrently only using 9&nbsp;MB.</p><p><span class="CITEREFENTRY"><span class="REFENTRYTITLE">top</span>(1)</span>automatically updates this display every two seconds; this can be changed with the <varclass="OPTION">s</var> option.</p></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="mount-unmount.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="basics-daemons.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Mounting and Unmounting File Systems</td><td width="34%" align="center" valign="top"><a href="basics.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Daemons, Signals, and Killing Processes</td></tr></table></div></body></html>

⌨️ 快捷键说明

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