Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99.

Similar presentations


Presentation on theme: "Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99."— Presentation transcript:

1 Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99

2 What is a “Process”? --A program in execution --Only one process is actually executing at a time What Sys Administrator can do with processes? --Monitor the status of processes --Control CPU time a process can get --Send signals to a process --Suspend or halt process execution

3 Components of a process: Address space –segments of program code –variables –stack –extra information Internal Data structures –address space map –current status –execution priority –signal mask –owner

4 What we are interested? PID: Process Identification Number PPID: Parent Process ID UID & GID: Creator’s User ID and Group ID EUID & EGID: “ what resources can be accessed?” Priority and Nice Value: “how much CPU time to receive?” Control Terminal: the default linkages for standard I/O and error channels

5 Life Cycle of A Process when system boots, kernel creates several processes autonomously New processes are created by other processes. (like new humans!) All processes except those kernel creates are descendants of init, which always has PID 1.

6 Life Cycle of A Process-- Contd. An existing process clones itself using system call fork to create a new process. The new process use exec system calls to begin execution of a new program. When a process completes, it calls a routine named _exit to notify the kernel that it is ready to die. (--Zombie)

7 Process States StateMeaning RunnableThe process can be executed SleepingWaiting for some resources SwappedNot in memory ZombieTrying to die StoppedSuspended(not allowed to execute)

8 Signals Unix defines a set of signals for software and hardware conditions that may arise during the normal execution of a process. A process can specify an action for a signal, either: –catching the signal with a handler –or taking the default action Each signal has a default action that may be any one of –ignoring the signal –terminating the process(& generate a core dump) –stopping the process Signals KILL and STOP can not be caught, ignored or blocked

9 Kill : Send Signals Syntax : Kill [-signal] pid Kill -l displays the available kill signals umbc9[1]% kill -l HUP INT QUIT ILL TRAP ABRT EMT FPE KILL(9) BUS SEGV SYS PIPE ALRM TERM(15) USR1 USR2 CHLD PWR WINCH URG IO STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ Kill pid defaults to sending TERM(15) Kill -9 pid last resort -- “Nuke” without mercy

10 Priority and “nice value” Process with highest “internal priority” gets to run first “Nice Value” -- how the process should be treated in relationship to other processes contending CPU BSD: -19 ~ +19 ATT: 0 ~ 39 Lower value => Higher priority nice to set “nice value” at the process creation renice is used to change the value during process execution

11 Monitor Processes ps --Processes Status ( “snapshot”) –ps -aux (ATT) –ps -ef (BSD) top - display information about the top cpu processes A dynamically updated “big picture”

12 actaeon.cs.umbc.edu[112] ps -aux | grep Jun |more USER PID %CPU%MEM SZ RSS TT S START TIME COMMAND root 1260 0.0 0.3 1560 1224 console S Jun 03 0:00 /usr/lib/saf/ttymo root 8980 0.0 0.3 1568 1296 ? S Jun 04 0:00 in.telnetd root 8982 0.0 0.5 2608 2200 pts/18 S Jun 04 0:00 login -p -d /dev/p burt 8983 0.0 0.2 1192 1016 pts/18 S Jun 04 0:00 -csh burt 9006 0.0 0.2 824 696 pts/18 S Jun 04 0:00 script burt 9007 0.0 0.2 896 720 pts/18 S Jun 04 0:00 script burt 9008 0.0 0.2 1192 1048 pts/20 S Jun 04 0:00 sh -i burt 9019 0.0 0.4 1952 1704 pts/20 S Jun 04 0:00 tcsh burt 9030 0.0 0.2 1192 1040 pts/20 S Jun 04 0:00 /bin/csh jiao 10004 0.0 0.2 848 744 pts/11 S 10:05:34 0:00 grep Jun root 10346 0.0 0.3 1568 1104 ? S Jun 01 0:00 in.telnetd root 10348 0.0 0.4 2560 1832 pts/5 S Jun 01 0:00 login -p -d /dev/p root 12220 0.0 0.3 1552 1256 ? S Jun 02 0:00 in.rlogind root 12222 0.0 0.5 2608 2160 pts/32 S Jun 02 0:00 login -d /dev/pts/ ykatsn1 9520 0.0 0.2 920 664 ? S Jun 01 0:00 /bin/sh /usr/local ykatsn1 9522 0.0 0.418912 1864 ? S Jun 01 0:00 (dns helper) ykatsn1 9550 0.0 0.2 920 696 ? S Jun 02 0:00 /bin/sh /usr/local ykatsn1 9553 0.0 0.418920 2008 ? S Jun 02 0:00 (dns helper)

13 actaeon.cs.umbc.edu[114] top last pid: 10096; load averages: 1.01, 1.03, 1.03 10:19:54 117 processes: 115 sleeping, 1 running, 1 on cpu CPU states: 0.0% idle, 97.4% user, 2.6% kernel, 0.0% iowait, 0.0% swap Memory: 512M real, 66M free, 129M swap in use, 371M swap free renice 5 9521 PID USER THR PRI NICE SIZE RES STATE TIME CPU COMMAND 9521 ykatsn1 1 -15 0 22M 3432K run 138.0H 96.54% netscape 9551 ykatsn1 1 33 0 34M 22M sleep 65:23 1.44% netscape 10096 jiao 1 27 0 1584K 1480K cpu 0:00 0.99% top 9499 crowder 1 33 0 4512K 3072K sleep 0:01 0.05% pine 5263 root 1 33 0 1584K 880K sleep 1:15 0.01% rpc.nisd_resolv 5262 root 1 33 0 3128K 1944K sleep 68:58 0.01% ypserv 115 root 1 33 0 2080K 1184K sleep 6:04 0.00% rpcbind 266 root 1 33 0 2552K 872K sleep 14:42 0.00% sshd1 25571 ykatsn1 5 34 0 39M 16M sleep 1:12 0.00% matlab 235 root 1 33 0 912K 440K sleep 1:10 0.00% utmpd 256 root 1 34 -12 2280K 608K sleep 1:04 0.00% xntpd 223 root 16 33 0 2912K 2336K sleep 0:49 0.00% nscd 3307 squiro 1 6 33 0 2512K 1760K sleep 0:31 0.00% windu_registryd 3411 squiro1 4 34 0 18M 3880K sleep 0:28 0.00% Medit 3706 squiro1 4 34 0 18M 3880K sleep 0:28 0.00% Medit

14 Special attentions NOHUP : Protect Background Process $ nohup command & Errant Processes For more information, please refer to Chapter 29.

15 Any Questions?


Download ppt "Chapter 5 Controlling Processes Xiaoli Jiao 6/8/99."

Similar presentations


Ads by Google