Linux操作系统实验.docx

上传人:王** 文档编号:895018 上传时间:2024-02-22 格式:DOCX 页数:24 大小:62.37KB
下载 相关 举报
Linux操作系统实验.docx_第1页
第1页 / 共24页
Linux操作系统实验.docx_第2页
第2页 / 共24页
Linux操作系统实验.docx_第3页
第3页 / 共24页
Linux操作系统实验.docx_第4页
第4页 / 共24页
Linux操作系统实验.docx_第5页
第5页 / 共24页
Linux操作系统实验.docx_第6页
第6页 / 共24页
Linux操作系统实验.docx_第7页
第7页 / 共24页
Linux操作系统实验.docx_第8页
第8页 / 共24页
Linux操作系统实验.docx_第9页
第9页 / 共24页
Linux操作系统实验.docx_第10页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《Linux操作系统实验.docx》由会员分享,可在线阅读,更多相关《Linux操作系统实验.docx(24页珍藏版)》请在优知文库上搜索。

1、Project1SystemsProgrammingPractice:TheYalnixShellEducationalObjectives:Studentscometothiscoursewithvariousexperiences.Formanypeoplethisprojectwillbepracticeand/orawarmup.Forothers,itW川bealearningexercise.Regardlessofyourbackground,bytheendofthisproject,wehopethatyouwillcomfortablyandconfidentlybeabl

2、etodothefollowing: Developclear,readable,well-documentedandwell-designedprogramsintheCProgrammingLanguage. DevelopsoftwareintheUnix/Linuxusingtoolssuchasgcc,gdb,andmake. 1.ocateandinterpreting,manpagesapplicabletoapplication-levelsystemprogramming. UsethePOSIX/UnixAPItosystemfunctionstomanageprocess

3、andsessionsaswellasusesignalsandpipesforinter-processcommunication. Understandinghowsynchronizationmightbecomeproblematicinlightofconcurrency. Understandhowtocommunicateandcooperatewithaprojectpartner.ProjectOverviewInthisprojectyouareaskedtoimplementasimplecommand-interpreter,a.k,a.shell,forLinux.T

4、heshellthatyouwillimplement,knownasysh,shouldbesimilartopopularshellssuchasbash,csh1tcsh1zsh,&c,butitisnotrequiredtoimplementasmanyfeaturesasthesecommercial-gradeproducts.Althoughwedontrequireallofthe*,bellsandwhistlesthatareincorporatedintocommercial-gradeproducts,yshshouldhavemuchoftheimportantfun

5、ctionality: Allowtheusertoexecuteoneormoreprograms,fromexecutablefilesonthefile-system,asbackgroundorforegroundjobs. Providejob-control,includingajoblistandtoolsforchangingtheforeground/backgroundstatusofcurrentlyrunningjobsandjobsuspension/continuation/termination. Allowforthepipingofseveraltasksas

6、wellasinputandoutputredirection.Withrespecttotheotherprogrammingassignmentsthissemester,andmanyothersinyourexperience,thisislikelytobeasmallproject,butwewantyoutoapproachitasifitisabiggerandmorecomplexprojectsothatyouarepreparedfortheremainingprojects.Specifically,we,dlikeyoutodothefollowing: Usethe

7、makeutilitytobuildyourproject Useadebuggerinsteadofprint-ad-huntdebuggingwheneverpractical. Produceclean,well-documented,andwell-designedsolutions.SpecificationFormYoursolutionshouldbeanapplicationprograminvokedwithoutcommand-lineparametersorconfigurationfiles,&c.Ifyouwanttobefancyandsupportforareso

8、urcefilesimilartothoseusedwithcommercial-gradeshells,e.g.cshrc,you,reawelcometodothis.But,likecsh,yourshellshouldfunctioncorrectlyinabsenceofthisfile.1.ook-and-FeelThelookandfeelofyshshouldbeSimilartothatofotherUNIXshells,suchasbash,tcsh,csh,&c.Forexample,yourshellsworkloopshouldproduceaprompt,e.g.,

9、ysh,acceptinputfromtheuser,andthenproduceanotherprompt.Messagesshouldbewrittentothescreenasnecessary,andthepromptshouldbedelayedwhenuserinputshouldn,tbeaccepted,asnecessary.Needlesstosay,yourshellshouldtakeappropriateactioninresponsetotheuserSinput.InternalCommandsvs.ExternalProgramsInmostcases,theu

10、ser*sinputwillbeacommandtoexecuteprogramsstoredwithinafilesystem.We,Ilcalltheseexternalprograms.Yourshellshouldallowtheseprogramstoexecutewithstdinand/orstdoutreassignedtoafile.ItshouldallowprogramsI/Otobechainedtogetherusingpipes.Forourpurposes,acollectionofpipedprocessesorasingleprocessexecutedbyi

11、tselffromthecommandlineiscalledajob.Whenexecutingbackgroundsjobs,theshellshouldnotwaitforthejobtofinishbeforeprompting,reading,andprocessingthenextcommand.Whenabackgroundjobfinallyterminatesamessagetothateffectmustbeprinted,bytheshell,totheterminal.Thismessageshouldbeprintedassoonasthejobterminates.

12、ThesyntaxfordoingthiswillbedescribedinthesectionofthisdocumentdescribingtheshellSparser.Yourparsershouldalsosupportseveralinterna!commandsthesecommands,ifissuedbytheuser,shoulddirecttheshelltotakeaparticularactionitselfinsteadofdirectingittoexecuteotherprograms.Thedetailsofthisarediscussedinthesecti

13、ondescribinginternalcommands.Foregroundvs.BackgroundJobsYourshellshouldbecapableofexecutingbothforegroundandbackgroundjobs.Whereasyourshellshouldwaitforforegroundjobstocompletebeforecontinuing,itshouldimmediatelycontinue,prompttheuser,&c,afterplacingajobintothebackground.CommandlinesWhentheuserrespo

14、ndstoaprompt,whattheytypecomposesacommandHnestring.Yourshellshouldstoreeachcommand-linestring,untilthejobisfinishedexecuting.Thisincludesbothbackgroundandsuspendedjobs.Theshellshouldassigneachcommand-linestringanon-negativeintegeridentifier.Thedatastructureusedtostorethejobsshouldallowaccesstoeachel

15、ementusingthisidentifier.Oncetheactionsdirectedbyacommand-linestringarecompleted,yourshellshouldremoveitfromthedatastructure.Identifierscanberecycledifyouchoose.Pleasenotethatthisdatastructureshouldkeeptrackofwholecommandlinestrings,notjustthenamesoftheindividualtasksthatmaycomposethem.Youshouldnotk

16、eeptrackofcommandlinestringsthatcontaininternalcommands,since,bytheirnature,theywillcompletebeforethisinformationcouldbecomeuseful.InternalCommandsThefollowingaretheinternalcommands.Ifaninternalcommandissubmittedbytheuser,theshellshouldtakethedescribedactionsitself.exit:Killallchildprocessesandexityshwithameaningfulreturncode.jobs:Printoutthecommandlinestringsforjobsthatarecurrentlyexecutingi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > linux/Unix相关

copyright@ 2008-2023 yzwku网站版权所有

经营许可证编号:宁ICP备2022001189号-2

本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!