Ȼ/03

Top / Ȼ / 03

Process and Job: ץȥ, ޥˤĤ

unix ϥޥƥǤꡤ桼Ϥβä¤Ѥ٤Ǥ. gui ǤľŪǤޥ cui ǤϤξ֤ˤ. Τᡤcui 鿴Ծ֥桼ϤäΥޥ dos Τ褦ʥ󥰥륿ĶȤޤѤʤ֤ unix cui ĶѤƤ뤳Ȥޤ޸. ϻ̵֤̤Ȥ. ǺμȤǤϡ桼ץ䥸֤椹ȤϤɤȤؤ֡

ơ桼鸫硤ץȥϤۤȤɥ쥹˷ҤäƤꡤ̤ɬפ;ʤ. ΰ٤ˤä򤬿ޤʤȤ¿.

ǥץȥΤ˶̤Ƴؽ򤷤Ƥ餽ȤʤȤŪȤ.

ޥȤ
Ʊʣν򤳤ʤȡ⤷Ϥν. ԥ塼ξ硤νȤϤץΤȤȻפäƤ褤.
ޥʥƥȤƤϡunix, windows, mac os ʤɤ󤲤. դˡdos ʤɤϥ󥰥륿ƥǤꡤ(¼Ūˤ)٤˰ĤΥץषưʤ.
unix ƥबޥƥǤ뤳Ȥ顤ʲ˲⤹ץ & 椬ɬפȤʤäƤ.

Process: ץȤ

ץ
unix Τ褦ʥޥƥǤϡƱ¿ΥץबưƤ. ĤΥץɤߤ͡ʵǽ鹽Ƥ. ǡǽưʬΥ뤳Ȥǡ͡ʽǽΨɤĤʬ䤹˹ԤʤȤǤ.
λΡԥ塼ưǾñ̤ץȸ(ä). (ĤޤꡤĤΥץʣ⤷ϰĤΥץʤ).
ºݤϡư֤꥽(Resource, )򤵤˸ΨŪѤ뤿ˡץ򤵤˺ʬ֥åɡפȤǰ. åɤϤ켫ΤǤϤޤΩ¸ߤǤϤʤᡤ桼ǤǾñ̤ϥץȤȤˤʤ.

äơԥ塼ưϡ¿(ۤΩ)ץƱưƤפ򤹤Ф褤.
ץ
unix ǤϤܾۤ¿Υץ(ŪƱ)ưƤ. λġΥץ()ߤꡤ ̤ͥ岼ꤹ뤳ȤǤʤȡ ȥ֥뤬Ȥʤɤ˥ƥߤ뤷ʤʤȤˤʤ.
ġΥץưȥƥऽΤΤưΩˤ뤿󶡤ʡ 줬ץǤ.
ޤץŬڤ˹ԤʤȤˤꡤƥΤΥѥեޥ󥹤夲뤳ȤǽǤ.
ץοƻҴط
unix ǤϡƤΥץϤʤ餫Υץˤä. ֿƻҴطפȸʤơȤΥץ򿷤ץ ֿƥץפȸƤ.
ֻҥץפΡֻν(Ӿ֤ΥץǤ뤳)פ򤹤ΤϿƥץܤǤ뤿ᡤ ҥץƥץ˻ʤʤФʤ.
äơ餫ͳˤƥץ˻Ǥޤä硤 Ӥˤʤäҥץν񤷤ʤ뤳Ȥ.

To know the status of processes: ps command: ץξ֤Τ: ps ޥ

ץξ֤Τˤϡps ޥɤѤ.

Τޤޤȡּʬ¹Ԥץץɽʤ. ¾ͤ¹ԤƤץʤɤ⸫Ȥϡ ŬڤʥץѤɬפ.

, UNIX ϤʤŪ ps␣axu ǤȤꤢ褤 cygwin Ϥ塤ps Ǥ褤. Windows ΥץˤĤƤ⸫Сps␣-aW ȤƤߤȤ褤 ܤΤꤿȤϡman ps ǥ饤ޥ˥奢Ҥ

examples of ps command: ps ޥɤλȤˤ㤤

ps
 PID TTY          TIME CMD
 29452 pts/0    00:00:00 sh
 29475 pts/0    00:00:00 tcsh
 31982 pts/0    00:00:00 ps
ps␣axu
 USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
 root         1  0.0  0.0  1504  352 ?        S     2010   0:01 init [2]
 root         2  0.0  0.0     0    0 ?        SN    2010   0:00 [ksoftirqd/0]
 root         3  0.0  0.0     0    0 ?        S<    2010   0:00 [events/0]
 ά
 daemon   10220  0.0  1.2 16972 11564 ?       S    23:29   0:00 /usr/local/apache2/bin/httpd -k start
 paoon    10221  0.0  0.0  2496  848 pts/0    R+   23:30   0:00 ps axu

ps ޥɤǸΤפʤΤ⤷Ƥ.

USER
桼̾. ΥץѼ.
) ̾桼ϡʬѤƤץǤʤ.
PID
ץ ID. ơΥץ˸ֹͭ. ʹ֤ǸСĿ̾Ǥ. ץϤ PID ܤȤƹԤʤ.
%CPU
cpu Ψ.
%MEM
Ψ.
tty
ü̾. ΥץɤΡüפ°Ƥ뤫򼨤.
STAT
ץξ.
warning.png ȥ֥Ω!
ʸĤ줾줢֤̣. פʤΤ򼨤Ƥ.

S ץ sleep (ܡϴλԤ)Ǥ.
R ץϼ¹Բǽ.
D ץϥǥϴλԤǤ.
T ץ(stop)Ǥ.
Z ץϥ(zombie, "Ǥ")Ǥ.

stat 򸫤Хץξ֤狼. T Z Ȥ֤ϰ۾֤򼨺. ޤĹ D ΤޤޤȤ⡤ǽ⤤.
command
ޥ̾Ȱ

notes.png ½: ps ޥɤѤơʬ¹ԤƤʣΥץƤˤĤơξ֤ɤʤäƤ뤫Ĵ٤补

To know the status of processes: top command: ץξ֤Τ: top ޥ

top ޥɤǡץξ֤ưŪפġϢ³Ūפˤߤ뤳ȤǤ. ̾ϡCPUΨι⤤˥ץưŪ¤ؤɽ뤬Ρ¤ؤ˻ȤܡפϼͳѤ뤳Ȥ롥

notes.png ½: top ޥɤ¹Ԥư򸫤Ƥߤ롥ޤ¹ ? 򲡤¹˲Ǥ뤫İ补

Control of processes: launch: ץ: ץ롤ư

ץȤϾ˽Ҥ٤褦˥ץñ̤Ǥ뤿ᡤ 桼鸫Ȥץ¹Ԥ뤳Ȥ¨ץ뤳ȤǤ.
դˡץμ¹Ԥ˽äȤˤϡ Υץˤäƺ줿ץƾǤȤȤˤʤ.

Control of processes: change of priority: ץ: ץͥ٤ѹ

ץˤϡ̡ͥפȤΤꡤ̤ͥ⤤˼¹Ԥ褦ˤʤäƤ. λȤߤˤꡤ͡ʥץƱưƤʹ֤ˤȤäƲŬ˰褦ˤʤäƤ.

index of priority: ̤ͥ򼨤ɸ

塼ͥ
0 127 οǡͥ褵롥
nice
οȥץʤʤɤ, ͥ٤ꤵ. -20 20 ٤οǡͥ褵롥 ǥեȤ 0.

ʤߤˡץͥ٤ nice ͤ򸫤ˤϡ ps l ( ʸL()) ȤΤñ ɽΤPRI ͥ(Priority), NI nice Ǥ롥

change of priority: ̤ͥѹ

nice
ץ൯ư nice ͤꤹ륳ޥ.
warning.png csh ϤΥˤ nice ޥɤȤ߹ޤƤ뤳Ȥꡤƥ˴¸ߤ nice ޥ(/bin/nice)ȺƱʤ褦! ɤƯƱȤϰۤʤ뤿ᡤȤȤɬ饤ޥ˥奢Ĵ٤.

Gnome-Preferences.png hoge Ȥץ, ̾ nice ͤ 10 礭(= ̤ͥ)ưȤ /bin/nice␣hoge ȤФ褤(/usr/bin/nice ޥɤϥǥեȤ 10 niceͤ夲)
renice
ưƤץ nice ͤ䤹=̤ͥ򲼤.
ưΥץΤǥԥ塼ȿߤʤʤɤξˡ ץͥ٤򲼤ƺȤŬˤ롤ŪѤ.

warning.png ̾桼ϥץ̤ͥ򲼤뤳Ȥʤѡ桼̤ͥ夲롥

Control of processes: termination: ץ: ץλ

unix Υץˤϡ֥ץ̿פȤäƥץƱΤ̿ȤߤäƤ. Υץ̿ΤåεǽĤΤȤơ֥ʥפ. ΥʥץĤ뤳ȤˤäơץߤꡤƵưꡤǤ. ʬѤƤץˤʥʤ

ʥץĤˤϡ
kill␣-ʥ␣pid
Ȥ. ʥϸҤ֥ʥ̾פ֥ʥֹפǻꤹ.
ʥά TERM (=15) ꤷȤˤʤ.

ʥμϰʲ̤ꡥ

ʥֹʥ̾ʥΰ̣
15TERMTERMinate. λ. kill ޥɤΥǥե.
9KILLKILL. ֶ׽λ. Υʥäץɬ.
2INTINTerrupt. ü(CTRL-c)Ȥ̣. Υʥȥץϻ.
3QUITQUIT. üǽλ(CTRL-\)Ȥ̣. Υʥȥץ(core Ǥ).
18TSTPTerminalSToP. ü(CTRL-z)Ȥ̣. Υʥȥץ()ߤ.
17STOPSTOP. ֶ. Υʥȥץɬߤ.
19CONTCONTinue. ߾֤Υץμ¹ԤƳ.
1HUPHangUP. üڤ줿ȤȤ̣. ̤ΥץϤΥʥȼ¹Ԥߤ뤬 Ƶư̤ʥ⡼ɤ˰ܹԤץ¿Τդɬפ.

ɽʬ褦ˡɤƤ⤽Υץ򻦤ϡ
kill␣-9␣pid
Ȥ뤫
kill␣-KILL␣pid
ȤФ褤.

warning.png state D Υץ䡤zombie ץˤ kill␣-KILL ͭǤʤ礬. ϡä˻پ㤬ʤ(^-^)پ㤬ꤽäԤ̤Τɤ.
warning.png ʥ "HUP" pid "1" "0" "-1" ̤ʰ̣ǻȤ뤳Ȥ¿Τǡ褯狼ʤϻȤʤ褦դ뤳. ܤˤäƤߤȤ춸ʿͤϼ unix ʤɤǥѡ桼ˤʤäơ kill␣1, kill␣-KILL␣-1 ʤɤȤäƤߤ褦(^-^).

Control of processes: to ignore the termination order "HUP": ץ: ü HUP ̵뤵

ץबưǤäƤ⡤üλȤꤹ̾ϤΥץϽλƤޤ. ϡΥץưĶλľˤΥץФƾ HUP ʥäƤ뤿Ǥ.

̤η׻򤹤Ȥʤɤˤ ֥ȤץưĤŤޤޤǤߤ ȤȤ.
Ȥˤϡ nohup ޥɤѤ nohup␣ޥ̾ ȤƥץưȡȤƤ⤳Υץबư³褦ˤǤ.

warning.png ޥɤꤷʤǤ nohup ȤƤޤȡʹߤΥޥƤ nohup ˤʤȥ֥ǽ⤤Τǡʤ褦ˡ



notes.png ½: μǥץƤߤ.

  1. ü emacs␣-nw Ϥ emacs ư.
  2. emacs ưƤ֤ CTRL-z Ȥơemacs ߾֤ˤ(CTRL-z ߾֤ϸ).
  3. ps ޥɤƤߤơemacs ¸ߤȤξ֤İ.
  4. top ޥɤƤߤơemacs ¸ߤȤξ֤İ.
  5. ps ޥɤ emacs PID İkill ޥɤѤ emacs λ.
  6. psޥɤ emacs ¸ߤʤ(λ)Ȥǧ롥

Job:

֤Ȥϡ(뤫鸫)ԥ塼Ǽ¹Ԥ֤ñ̤γǰǡ ְϢλŻ򤷤Ƥ(ʣ)ץ ΤȤǤ.
ޤñ˸С̿ᤷ(ʬ)̿θǤޤפǤꡤ ʹ֤ˤȤäưĤνȸʤΡȻפФ褤. history ޥɤǡְʬפΥޥɤȻפäƤ褤.

Why do you introduce the new concept "job"? ˥ץȤǰΤ, ʤ虜虜 ֤ȤǰΤ?

ץȤΤϡޤǡ֥ԥ塼¦鸫׳ǰǤ. Τdzμ¤ʳǰǤ뤬ѼԤȤδطϤۤȤɹθƤʤ.
ǡ֥桼ˤȤäƤμ¹ñ̡פȤƥ֤Ȥǰ Υñ̤桼ָʤ긫褦ˤפ뤳Ȥ ޥȤ䤹롤ȤΤ֤ȤǰκήۤǤ.

Foreground and background: ե饦,Хå饦

Ͽʹ֤ȡŪפưΤܤǤ뤿ᡤ ξľʣΥץƱưȥܡɤ𤹤ΤϥߥߥǤ(^-^).
ޥƥǤ unix ǤΤˡ ǤƱʣΥץȤʤȤΤ̣ʤ. ǡֿʹ֤äʤȤ른֤Ĥפ ֤Ǥʤ(ʣ) 櫓뤳ȤǥޥǽȤƤ.

jobs.png

ե饦
̤ƿʹ֤ΥܡϤ른֤򤤤. Ĥޤꡤ̾ȤäƤ֤Υ֤ϥե饦ɤˤΤǤ.
warning.png ü1Ĥ˥ܡɤ1ĤʤΤǡե饦ɥ֤ü1ĤˤĤ1Ĥ¸ߤǤʤ
Хå饦
ʹ֤ΥܡϤʤ֤ưƤΥ֤ ֥Хå饦ɤưƤפȸ. ξ֤ư른֤ʣäƤ褤.
߾
ưϤƤ뤬ưߤƤ.
ե饦ɤˤХå饦ɤˤʤʤä֤ Ūˤξ֤˰ܤ뤳Ȥ⤢. ޤ֤ե饦ɤХå饦ɤػäƤȤξ֤ȤƤѤ.

To know the status of jobs: ֤ξ֤Τ

Υ뤫鸫ȤˤɤΥ֤ɤ֤ˤ뤫ϡ
jobs
ޥɤΤ뤳ȤǤ.

Gnome-Preferences.png jobs ޥ ¹.

[1]  - λ                          ls --color=auto -Fga -l |
                                 less
[2]  +                           emacs

ɽϺ顤
ֹ ޥɤȰ
ȤꥹȤˤʤäƤ. ֹˡ+פĤƤΤϡޥɤΥǥեȤоݤǤ뤳Ȥ̣Ƥ. (ϰ礭ֹ)

ʤߤˡǤĤΥ֤ǡ׾֡Ĥޤ߾֡פǤ뤳Ȥ狼.

notes.png ½: ʸü emacs␣-nw␣& Ȳ٤Ϥʤɤ, jobs ޥɤͻҤƤߤ.

Control of jobs:

Ȥϡ֤򻰾֤Τ֤¾ξ֤ؤȰư뤳Ȥ䡤 ץƱֻ֤פ뤳Ȥ.

֤ˤޤˤäƾ˺ܤޤΤ褦ʻĤξ֤롥 ˤ褦ʥޥɤѤƥ֤ξ֤뤳Ȥ 濴Ȥʤ.
ܺ٤ϰʲ̤ꡥ

Control of jobs: launch: : ֤

̤ƥץ¹ԤȤ 줿Υޥ()֤Ȥ. λ˥֤ɤξ֤˹ԤΤ褦ˤʤäƤ롥

̾ϥե饦ɾ֤ˤʤ뤬ư˥ץ & ĤȥХå饦ɾ֤ˤʤ

Gnome-Preferences.png ¹: window system ưƤȤ ü emacs␣& Ȥȡemacs ǡ׵ưΤ뤬줬Ǥ.

Control of jobs: from background to foreground: : Хåե

fg␣%ֹ
Υֹĥ֤ե饦ɤذܤ(Ϥʹˤ).

warning.png ֤ ե Хå ľܰܤˡ̵ե Хå ȷͳˡ( CTRL-z bg␣%ֹ Ȥ)ΤǤȤ

Control of jobs: between foreground and suspended: : ե

CTRL-z
ե饦ɥ֤߾֤ˤ.
뤽ΤΤϤߤʤ褦ˤʤäƤ(㳰).
ߤϡ suspend ޥ.
fg␣%ֹ
Υֹĥ֤ե饦ɤذܤ(Ư֤ˤ).

Control of jobs: between suspended and background: : Хå

bg␣%ֹ
Υֹĥ֤Хå饦ɤ˰ܤ(ư).
stop␣%ֹ
Υֹĥ֤߾֤ˤ(ư. λǤϤʤ).

Control of jobs: to kill them: : ֤򻦤

ե饦ɥ֡¨ʹ֤äʤưƤ른֤ CTRL-c ʤɤǻȤǤ. JNorth_arrow-right-sm.png 01 ޥδ Ǥ⼨̤Ǥ.
뤽ΤΤϤǻʤʤ褦ˤʤäƤ(㳰).

Ǥʤ(¾ξ֤ˤ른)ϡ jobs ޥɤǤΥֹĴ٤ơ
kill␣%ֹ
ȤФΥ֤򻦤ȤǤ.

notes.png ½: μǥƤߤ.

  1. touch ޥɤѤƥե򿷤.
  2. äե ü vi emacs Խ(֤)Ŭ˿Խ񤭹.
  3. vi or emacs λˡߤ뤳Ȥǥ(֤).
  4. less ޥɤѤԽե򸫤(֤ & ).
  5. date ޥɤѤĴ٤ơ(֤ & ).
  6. fg ޥɤѤ vi or emacs (ߥ֤ե饦ɤ)
  7. ۤĴ٤񤭹Ǥ, vi or emacs λ(֤).
  8. Ƥ, less ޥɤѤԽե򸫤ơۤɤ񤭹ߤ¸Ƥ뤳Ȥǧ(֤ & ).

Report: ݡ

ʲβˤĤǽ¤긭ĴȹͻԤ
AppliedMath7-Report-03
Ȥ̾Ĥ e-mail ˤƶ˥ݡȤȤФ. ʤݡȤ e-mail TeX Ǻ̤ˤФƤ褤.

Exercises:

  1. ܻμ½ʬ򤹤٤ƹԤˤĤơ֤ȡ𤻤(ޤʤɤȤΤϥ)
  2. ֤߾֤ˤˡʣҤ٤补
    ޤκȤºݤˤäƤߤ. ͻҤ script ޥɤǵϿƤơεϿФ𤹤뤳.
  3. kill Ǥץʤ礬̤꤫ͤ. Τ3󤲤ƤȲ⤻.
  4. ֤ 碌 5ĤۤƤ¸֤ˤ ֤򼫺ߤܤ.
    ͻҤ script ޥɤǵϿƤơεϿФ𤹤뤳.

about Icons, ClipArts

For details, see JNorth_arrow-right-sm.png this.


źեե: filejobs.png 62 [ܺ]