资源描述:
《进程管理实验二.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#includemain()intp,x;P=fork();if(P>0){x=fork();if(x>0)printf('TatherM);elseprintf(uchild2H);}elseprintfC'childl1');)实验步骤及输出结果:[test@localhost桌面]$gcc-o11.c[test@localhost桌面]$./Ifather[test@localhost桌面]$chilc!2childl2、运行以下程序,分析程序执行过程中产生的进程情况。ttincludemain(){intp,x;
2、p=fork();if(p>0)fork();else{fork();fork();}sleep(15);实验步骤:编译连接gcc-oforktreeforktree,c后台运行./forktree&使用pstree-h查看进程树实验步骤及输出结果:[test@localhost桌而]$gee一oforktreeforktree・c[test@localhost桌面]$./forktree&[1]3952[test@localhost桌面]$pstree一hinit1NetworkManagei1dhelientI1{NotvvorkManagcr}
3、abrt
4、d
5、acpid
6、乙td
7、auditcl{auditd}
8、automount4*[{aulomount}]
9、avahi-daemonavahi-daemon
10、bonobo-activati{bonobo-activat}
11、clock-app1et
12、console-kit-dae63*[{console-kit-da}]
13、crond
14、2*[dbus-daemon{dbus-daemon}]
15、2*[dbusTdunch]
16、devkit-power-da
17、geonf-im-settin
18、gconfd-2
19、gdm-binarygdm-simple-slav1XorgI1
20、gclm-session-woignome-session1abrt-ap+I
21、bluet()()+I
22、gdu-not+I
23、gnome-p+I
24、gnome-p+I
25、gnome-v+I
26、gpk_upd+I
27、metacit+I
28、nautilusI
29、polkit-+restore+
30、rhsm-co+I1{gnome~+
31、gdm-uscr-switchIgcdit
32、—gnome-keyring-d2*[{gnome-keyting-}]
33、—gnome-screensciv
34、—gnome-settings{gnome-settings}
35、gnome-terminal1b
36、ashpstreeI
37、gnome-pty-helpeI1{gnome-terminal}
38、gnote
39、gvfs-dfc-volume{gvfs~afc-vo1um}
40、gvfs-gdu-volunie
41、gvfs-gphoto2-vo
42、—gvfsd
43、gvfsd-burn
44、gvfsd-computcr
45、gvfsd-mctadata
46、gvfsd-trash
47、haIdhald-runner1hald-addon-acpiI1hald-eiddon-inpu
48、ibus-xll
49、im-settings-daeibus-daemon1ibus-engine^pinI
50、ibus
51、-gconfI
52、pythonI1{ibus-daemon}
53、loop
54、mastei1pickupI1—qmgr
55、5*[mingetty]
56、modem-manage1、
57、notifiedtion-ar
58、notification-da
59、polkitd
60、pu1seaudio1gconf-helper
61、12*[{pulseaudio}]
62、rhsmcertd
63、rpc.idmapd
64、rpc.mountd
65、rpc.rquotadIrpc・statd
66、rpcbind
67、rsyslogcl2*[{rsyslogd}]
68、rtkit-daemon2*[{rtkit-daemon}]
69、
70、seahorse-daemon
71、sshd
72、trashapplct
73、udevd2*[udevd]
74、ndisks-daemonudisks-daemon
75、—wnck-applet
76、—wpa_supplic“rit1xinetd[1]+Done./forktree3、运行程序,分析运行结果。#includemain(){intp,x,ppid、pid;x=0;p=fork();if(P>0){printf(nparentoutputx=%dr++x);ppid=getpid();printf(fThiidnumberofparentis:pp
77、id=%dppid);Ielse{