ch13 进程

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

13.1„ObjectiveszCPUzshellzzzzLINUXzLINUXzCtrl-CCtrl-DCtrl-ZCtrl-\;&()bgjobskilllimitnicenohuppspstreesleepsuspendtopulimit113.2„Anexecutingprogram=aprocess„LINUX„„LINUX„„213.3„Onatimesharing()systemwithonlyoneCPU:zMultipleprocessesareexecutedsimultaneouslybyquicklyswitchingtheCPUfromoneprocesstoanotherzTheshortCPUtime,thatisgiventoaprocessiscalledaquantum(100msec)zThetechniqueusedbythekerneltochoosethenextprocessthatgetstheCPUiscalledCPUschedulingcpuzCPUschedulingisimplementedinthekernel313.4„CPUschedulingonatimesharingsystem:zApriorityvalueisassignedtoeveryprocesszTheprocesswiththehighestprioritytakestheCPUnextzThesimplestschedulingalgorithmiscalledfirst-come-first-served(FCFS)zAnotheralgorithmassignshighestprioritytotheI/OBoundprocesses(ProcessesthatspendmostoftheirtimedoingI/O.Ex:vieditor)zRoundRobin(RR)AprocessgetstousetheCPUforonequantumandthentheCPUisgiventoanotherprocess,thenextprocessinthequeueofprocesseswaitingtousetheCPUzLinuxusesacombinationofthesealgorithms413.5LinuxLinux„LINUX„„„„Linux2.45;Linux2.67513.6LinuxLinux613.7LinuxLinux„TASK_RUNNING()CPUrun_listTASK_RUNNING„TASK_INTERRUPTIBLEsignal„TASK_UNINTERRUPTIBLE:TASK_UNINTERRUPTIBLE„TASK_ZOMBIE:„TASK_STOPPEDCPU„TASK_TRACED(2.6)„TASK_DEAD(2.6)713.8ShellShell„Shell„internal(built-in)commandshellLINUXshell.aliasbgcdcontinueechoexecexitfgjobspwdsetshifttesttimeumaskunsetwait„(externalcommand)shellgrepmorecatmkdirrmdirlssortftptelnetlpps„LINUXforkfork„Theforkingprocessisknownastheparentprocess()„Thecreated(forked)processiscalledthechildprocess()13.9shshellell(cont.)(cont.)„bashshellFigure13.2Figure13.2ProcesscreationviatheforksystemcallProcesscreationviatheforksystemcall13.10shshellell(cont.)(cont.)„„LINUXexec„shellforkexec13.11shshellell(cont.)(cont.)1313--3LINUXshell3LINUXshellsortsort13.12shshellell(cont.)(cont.)„Shellscript:aseriesofshellcommandsinafile„shell„Executionofashellscript:zshellshellshellshellzshellzshellshellshellshellzshelleofzshellshell„13.4,find13.13shshellell(cont.)(cont.)Figure13.4Figure13.4StepsforexecutionofashellscriptbyaLINUXshellStepsforexecutionofashellscriptbyaLINUXshell13.14shshellell(cont.)(cont.)1313--55shellshell13.15shshellell(cont.)(cont.)%psPIDTTYTIMECMD12675pts/00:03tcsh12695pts/00:03ps%bash$echoThisisBourneshell.ThisisBourneshell.$zsh[~]-%echoThisisKornshell.ThisisKornshell.[~]-%psPIDTTYTIMECMD12675pts/00:03tcsh15772pts/00:00bash15773pts/00:00zsh12695pts/00:03ps[~]-%^D[~]-%^D%tcshbashzsh13.16„Aprocesshasseveralattributes:zOwnersIDzProcessnamezProcessID(PID)zProcessstatezParentprocessIDzLenghtoftimetheprocesshasbeenrunning13.17(contd.)(contd.)„psSystemV-N-a-e/-A-jPIDIDID-l-pID-uulistulistUID(UID)-ttlisttlisttlistpsBSDUulistulistUID(UID)efASCII-artjPIDIDIDlpIDttlistulistUIDtlistps13.18(contd.)(contd.)„Examples:(P.229)zps-l(Displayinlongformat)zps-A|more(Displayallprocessesrunningonthatsystem)zps-j(DisplaytheparentPID,groupID,sessionIDzps-uuserlist(Displayprocessesownedbyspecificusers)zpsr(Showprocessesthatareinrunnablestate)zpsf(Displayprocesshierarchyintreeview)1813.19(contd.)(contd.)„$psPIDTTYTIMECMD19440pts/10:02-ksh18786pts/10:00ps20668pts/10:10vi„$ps–aPIDTTYSTATTIMECOMMAND7627pts/2S0:00login–sarwar7628pts/2S0:00-tcsh7666pts/2S0:00bash7828pts/2T0:00pine7829pts/2R0:41banner7831pts/2R0:00psa132DI/ONRCPUSTZW13.20(contd.)(contd.)„$ps-u147UIDPIDTTYTIMECMD14718802pts/10:00ps14719440pts/10:02ksh14720668pts/10:10vi$„$ps–lFUIDPIDPPIDPRINIVSZRSSWCHANSTATTTYTIMECOMMAND100121762876270021361228rt_sigSpts/20:00-tcsh0001217666762810020601244wait4Spts/20:00bash000121782876660040441192do_sigTpts/20:00pine000121782976661801104292_Rpts/249:22banner0001218007766617027401012_Rpts/20:00psl13.21(contd.)(contd.)133FUIDIDIDPIDIDIDPPIDPIDPIDPRININiceniceVSZ++RSS(K)WCHANCPU—STAT13.113.2TTY:TIMECOMMAND-f13.22(contd.)(contd.)„topCPUCPU„CPU„top„top„killPIDcommandkillstheprocessthathasthespecifiedprocessid(PID)2213.23AsamplerunoftheAsamplerunofthetoptopcommandcommand$top12:02pmup3days,9:04,2users,loadaverage:2.03,1.84,1.5369processes:65sleeping,3running,0zombie,1stoppedCPUstates:97.4%user,2.5%system,0.0%nice,0.0%idleMem:225312Kav,222464Kused,2848Kfree,59308Kshrd,4584KbuffSwap:529184Kav,16Kused,529168Kfree192048KbuffPIDUSERPRINISIZERSSSHARESTATLIB%CPU%MEMTIMECOMMAND7829sarwar140292292232R098.00.156:25banner8048sarwar3012041204972R01.30.50.00top7993vegdahl00772772644D00.30.30.02tar303root00000SW00.10.00.04rpciod1root00392384332S00.00.10.03init2root00000SW00.00.00.00kflushd3root00000SW00.00.00.00kupdate4root00000SW00.00.00.00kpiod5root00000SW00.00.00.00kswapdCtrl-C13.24AsamplerunoftheAsamplerunofthetoptopcommandcommand$kill8597$nice-10banner$topbanner12:12pmup3days,9:14,2users,loadaverage:1.00,1.16,1.3268processes:64sleeping,3running,0zombie,1stoppedCPUstates:0.5%user,1.3%system,98.0%nice,0.0%idleMem:225312Kav,219484Kused,5828Kfree,58504Kshrd,4584KbuffSwap:529184Kav,16Kused,529012Kfree189488KbuffPIDUSERPRINISIZERSSSHARESTATLIB%CPU%MEMTIMECOMMAND8111sarwar2019292292232RN098.00.18:29banner8261sarwar2012041204972R01.30.50.00topCtrl-C$1

1 / 44
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功