嵌入式课程设计_第1页
嵌入式课程设计_第2页
嵌入式课程设计_第3页
嵌入式课程设计_第4页
嵌入式课程设计_第5页
免费预览已结束,剩余3页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、心身转/礴嵌入式课程设计课程名称嵌入式系统设计与实践授课学期2016学年至2017学年第一学期学院XX专业XX学号XX姓名XX专题嵌入式系统设计与实践任课教师XX交稿日期2017年01月11日成绩阅读教师签名日期广西师范大学电子工程学院制1、实验目的通过编写多进程程序,使读者熟悉掌握fork()、exec()、wait()和waitpid()等函数的使用,进一步理解在Linux中多进程编程的步骤。2、实验内容该实当有4个进程,其中一个为父进程,其余3个是该父进程创建的子进程,其中第一个子进程运行“lsl”指令,第二个子进程暂停3s后运行“psef'指令,第三个子进程在暂停7s之后异常退

2、出,父进程先用阻塞方式等待第一个子进程的结束,并打印第一个子进程退出信息;然后再用阻塞方式等待第二个子进程的结束,并打印第二个子进程退出信息;最后用非阻塞方式等待第三个子进程的退出,待收集到第三个子进程结束的信息,打印第三个子进程退出的信息后,父进程就返回。本实验需要打开1个虚拟终端运行程序multie_proc_1657。此时观察这个进程的运行结果。本次实验运行的系统平台是Ubuntu-12.04。3、实验步骤(1)使用visio软件画出实验流程图;图1实验流程图(2)使用visio软件画出父进程繁衍子进程的流程图;fork()子进程1tfork()子进程2IFfork()子进程3图2繁衍子

3、进程流程图(3)启动虚拟机中的Linux操作系统,使用root用户登录系统,使用图形界面模式。打开终端,新建一个以自己的学号建立的用户名(以下简称为student1657)。公O畸rootgjstu-virtual-machine:/homestugstu-virtual-machine:-$su-root密码:useradd-mstudentl657passwdstudentl657rootgstu*virtual-machine:-#rootgstu*virtual-machine:一#输入新的UNIX密码:重新输入新的UNIX密码:passwd:已成功更新密码rootgstu-virtu

4、al-machine:rootstu-virtual-machine:/hone#总用量20drwxr-xr-xSrootroot40961月921:66,/drwxr-xr-x23rootroot49981月915:11*/drwxr-xr-x3Ip】Ipl40961月921:04Ipl/drwxr-xr-x21stustu40961月920:40stu/drwxr-xr-x2studentl657student16574096i月921:06studentl657/rootgstuvirtual-nachtne:/home#图3添力口用户student1657(4)在/home/stude

5、nt1657目录下创建名为2016011657的文件夹。创建一个权限可读写的multie_proc_1657.c文件;a.创建2016011657文件夹。萼若mroot(fl)stu-vlrtual-machine:/home/student1657/2016011657rootstu-virtual-machine:/home#IsIplstustudentl657rootstu-virtual*machine:/home#cdstudentl657rootstu-virtual'machine:/home/student1657#mkdtr2016011657rootstu-vtr

6、tual-machine:/home/studentl657#cd2016011657rootgstu-virtual-machine:/home/student1657/2016011657#|图4创建学号文件夹b.创建multie_proc_1657.c文件,并更改权限为可读可写可执行rootgstu-virtual-machine:/honie/st<jdentl657/26160116S7fftouchmultte_proc_1657.crootgstu-virtual-piachine:/harie/5tkidentl657/20160116S7#Ls-1息用量0-rw-r-r

7、-1rootroot01月921:49nultie_proc_16574crootstu-virtual-machine:/hone/st<id&ntl6S7/2616011657ffchmoda+rwxnultteproci657.crootstu-virtual-Fiachine;/horie/student!657/2©16011657#Is-1总用量0-ruxrwxrwx1rootroot01月921:49nultte_proc_lfiSTicrootstu-virtual-nachine;/hoine/studentl657/2616011657#.图5(1)

8、创建C文件和更改权限原先是修改为可读可写可执行,后期按要求再次修改权限为可读可写roat>stu-virtual-machine:/horne/student1657/2O16011657stustu-virtual-nachtne:su-root密码:rootstu-virtual-machine:cd/hone/student1657/2016Q11657rootstu-virtual-machine:/hone/studentl657/2016011657#Is-I总用量29-rw-r-r-1rootroot1671月1日11:19Makefile-rwxr-xr-x1rootro

9、ot73581月1011:25(nultte_proc_1657-rwxrwxrwx1rootroot21921月1609:44multte_proc_1657-rw-r-r-1rootroot254。1月1011:25multte_proc_1657.orootstu-virtual-machine:/home/student1&57/2016011657#chmod666multie_proc_1657.crootgstu-virtual-nachinei/home/studentlfi57/2ei6011657«Is总用量20-rw-r-r-1rootroot1671月

10、IO11119Makefile-rwxr-xr-x1rootroot73561月1011:25nultte_proc_16S7-rw-rw-rw'1rootroot21921月16&9:44nultlu_poi2_1657.c*rw-r-r-1rootroot25461月1911:25Fiuttie_proc_1657rootgstu-virtual-machine:/hone/student1657/2016011657#|图5(2)按要求修改的权限c.编写multie_proc_1657.c程序rootstu-virtuaUmachine:/home/student1657

11、/2016011657tncludecstdto.h>#lnclude<stdllb.h>ffinclude<sys/types.h>#include<unistd*h>#include<sys/wdi.t*h>tntmatn(votd)(childS.child;pid_tchildl,chtld2,chtldl=fork();tf(chiXdl=-1)(printf(Mchildlforkerrorn");ext(l);)elseif(chtldl=e)(prlntfClnchtldl:execute'Isif(exe

12、clp("Is"rnls'1,h-l",NULL)<0)(printf('chtldlexeclperrornn);)child?=fork();iffrhtld?=-1图6编写程序(5)以vi作为编辑器,编写关于上述程序的Makefile文件,编写完后通过make工具编译生成1个名为multie_proc_1657的目标文件;a.创建Makefile文件j1rootlstu-virtual-machine;/home/student1657/2016011657#viMakefile小尹rootstu-virtual-machine:/ho

13、ne/studen11&57/Z016011657#|图7创建Makefile文件b.编写生成Makefile文件root>stu-virtual*machine:/home/student1657/2016011657multte_proc_1657:multie_proc_1657,ogccHultie_proc_1657.o-omultte_proc_1657multie_proc_1657.o:multte_proc_1657.cgcc-cnultte_proc_1657*c*omultie_proc_1657*o图8编写Makefile文件rootgstu-virtua

14、l-machine:/hone/student1657/2016011657ffvtMakefilerootstu-virtual-machine:/home/student1657/2016011657#Is*1总用量8-rw-r-r-1rootroot1791月ID10:15Makefile-rwxrwxrwx1rootroot21921月1009:44nultte_proc_1657.crootstu-virtual-machine:/home/studentl6S7/2016011657ff|图9查看Makefile文件c.执行make命令Qtstu-vi.tUdl-MHuhine:/

15、hQMB/studRntl657/2016011657#rootstu-virtual-machine:/hone/student1657/2616011657#gcc-cnulti_pojl657.c-omultxe_proc_1657,ogccniultteproclAST-onultleprocifiS?rootstu-virtual-machine:/hoFie/studentl657/2ei6011657#总用量ZO-rw-r-r-'1-WKnx1-rwxrwxrwx1rootrootrootrootrootrootrootroot1677356219225401月1月1月1

16、月1010101010:5710:5009:4410:58viMakefilemake-fMakefileis-1Makefilenultte_prQC_1657nultte_proc_1657multie_proc_1657.orootstu-virtual-machine:/hone/student1657/26160116S7ff|图10执行make命令(6)打开虚拟终端运行程序multie_proc_1657;rootgstu-virtual-machine:/home/studentl657/2016G11657#*/nultte_proc_1657图11运行程序t*11:29-rw

17、xr-xr-x1root-rwxrwx广1root-rw-r-r-1rootraotstu-virtual-infatherprocessInchild?:Inchtld2:inchtldl:总用量20-rw-r-r-rwxr-xr-x-rwxruxrux'rw-r'-r-getchtldlIDrootrootrootrootroot73561月IB1112SmuLtte_proc_r&Ot21921月1909144mutie_proc_root254。1月ID11:25nultie_proc_machine:/hone/student1657/2O1601iaS7fr

18、sleepfor7sandthenexitsleepfarMsandthenexecuteexecute'Is-1'1rootroot1671rootroot73561rootroot21921rootroot2546exitcode08001111月月月月111-111:1911:2509i4411:25PIDPPI口CSTIMzTTY09:3739:3716571657.C1857*。./multteproc1657MakefilenuLtie_proc_16S7multte_proc_1657.cnultie_prtJG_16S7*oTIMECMOae:oe;oi00:G

19、O:0©0:00:6000:OO:00kthreaddksofttrqd/Dntgratlon/orootwatchdog/eroot&9:37cpdsetrootrootio99:3700:00:000e:oe;oekhelper1kdevtmpfsrootrootroot110fl091370913700:60:00OS:0Oi0060:GOiasnetnssync_supersbdL-品faultroot1400:00:00kntegri.tyd1图12(1)运行结果f&ot$tu-virtual-mathlrte;/home/studertt1w/zoiwi1

20、657朝图11.则)n:301I1»©Froot212fl09;37?©0:63:00|root222009:37?00:00:00root232009:37?00:00:00root242O09:37?00:63:00|root252B©9:37700:63:00crt262009:37?86:09:00root272009:37?00:00:00|root352B09:37?00:00:00root382009:37?90:00:00root392009:37?eO:0O:DO|root402009:37?00:03:DOroot412e09;37?

21、©0:03:00|root422Q09:37?00160:00root432009:37?00:00:06root442e09:37?00:00:00|root452B09:37?00:00:00root462009:37?S0:09:Q0root472e09:37?00:63:00|root4S2B09:37?00:90:00gt492fl09:37?rootso2e09:37?eoiooioo|rootSI2B09:37?00:03:00root522609137?00:09:00|rootS32e99:37r?ee:oa:0Oroot5。2009:37?00:00:00root

22、552e09:37?©0:60:00|root56Z009:37?00:00:00|root572fl09:37?86:09:60'khungtaskd'kswapde'ksmd;khugepaged'fsnotlfy_mecryptfs-k;cryptokthrotldscst_ehjBscst_eh_l;scsieh2scsi_eh_3;scsteh4'scsi_eh_5scst_eh_6Fscsteh7'scsi_eh_8;scsi_eh_9scsiehlOscsi_eh_ll;scst_eh_12scsi_eh_13;scsi_

23、eh_14;scst_eh15>csi_eh_16;scst_eh_17'scsiehlBscsieh19arkthea1图12(2)运行结果f®root612&09:37?00:00:root622009:37?00:00:rootfii2009:37?aaiee:root5。2009:37?fl0:OG:root652009:37?00:00:root662白电9f37?8SiOe:root67?白色9=37>AA-000080000089AAscsi_eh_23;'scst_eh_24;$csl_eh_2S;scsieh26,'scs

24、l_eh_Z7'scst_eh_2B'"crsiph>9'工IIWLLfIL_wW!root682009:37700:00:root712fl09:37?63:00:root992&09:37?00:00:WkJ00ae00nknLdil尸'scst_eh_30;5cst_eh_31kwarker/u:31root1862909i37?OOiOe;root12G2S09:37?09:60:root2Z52009:37?00:06:00001BBkworker/u:33devfreq_wq'nptpoU_9LJF1rootZ3120

25、09J37700:00:root2642&09:37?00:©G:root2312009;37?孙附00eo00L叩叮刃scsteh_32JJbdZ/sdal-SrootZB220日9:37?日日:。呼:root36S1009:37?Q3:0G:root3771009:37?00:00:1021A0Q*377ggext4-dio-unirfritjpstart-udev-bridge*-daemansbin/udevd-daemon:ibus-dwuEdn-system-fork-act/usr/sbin/noclei,i-managerusr/sbin/bluetoothd

26、rsysLogd-cS00(00jQQfMVroot5781009:37?00:00:root5301009:37?00:00:sy5log5521白05:37?白白:屯电:uhjqea100jaaitroroot5991009:37?00:00:avhi6971009;37?eo;oo:avahl66B6071309:37?SflifiG:root6191&©9:37?00:00:root6242009137?00:00;SI1oi:OS;oi.00IletworkManagerivaht'daemon:runningstu-vtrtuaavalhl-daemon:

27、chroothelperfusr/Lib/policykit-1/polkltd-nokf8mM图12(3)运行结果画E3*”河11:31±中rootstu-virtual-machine:/home/studentl6S7/20l60116571004Z1691fl09:39700:00:00/usr/bin/python/usr/ltb/untty-l.e106422151Q69:39/usr/ltb/untty-lens-nusic/unity-n106422381e09:39J00:03:00/usr/bin/python/usr/ltb/unity-sc1004226510

28、09:39?00:00:00/usr/lib/dconf/dconf-service106424ze1009:39?00:30:00/usr/lvb/gvfs/gvfsd-netadata100424Z5IBISg09:40760:00:00/usr/lib/deja'dup/dejd-dup/deja-d108427421906§19;02?00590:00/btn/sh-cgnone-terntnal1呢427432742s16:02?ee:&o:22gnone-terntnal106427480ie:02?00:00:00gnome-pty-helper1004

29、27492743&10:02pts/0eB:es:6sshroot"542749&10:02pts/0oe:ee:oosu-rootroot2.7622754014:«2pts/000:00:00-suroot28252e13:03?00100:00kworker/e:l100429562743epts/1shroot29S62956010:37pts/100:00:00su-rootroot2984295619:37pts/160:00:00-SU100430701g10:437ee;eo:07gedtt/hone/studentIfiST/Makeflieroot31832Q1日:55700:00:00kworker/0:2root3”62964Q11:26

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论