COMP20007Design of Algorithms

1Introduction1.1OverviewThe goalof thiscoursework istomake useof operatingsystemAPIs,particularlythePOSIX API,toimplementaprocesssimulatoron Linux.Your finalimplementation willbe basedupon principlesthatyou wouldfindinmodern operatingsystems,and willexploitsomestandardconcurrencytechniques.Completingallthetaskswillgiveyou agood understandingof:Key conceptsinoperatingsystems.The useofoperatingsystemAPIs.Implementationsofprocesstablesandprocessqueues.The basicsofconcurrent/parallelprogramming usingoperatingsystemfunctionality.Criticalsections,semaphores,mutexes,and mutualexclusion.Bounded bufers.C programming.Successfullyimplementingthecourseworkwillbeakeysteptowardsthelearningoutcomesforthismodule.To maximise your chances of completing this coursework successfully,and to give you thebestchance ofgetting agood grade,itisrecommend that you break itdown in the diferentstageslistedinSection3.Eachstepgraduallyaddsmorecomplexityandbuildsupkeyinsights.Onlythefinalversionofyourcode,which willincludeallcomponentsofthepreviousstages,shouldbesubmittedinMoodle.Onlythissubmittedversionwillbemarked.1.2Coding1.2.1ServersTutorialson how tologon totheserversareavailableintheLabsectionon theMoodle page.Whenof campus:From Windows:

–Setup ansshtunnelusing:plink-N-L2201:bann.cs.nott.ac.uk:22-P2222<username>@canal.cs.nott.ac.uk–When using WinSCP or Putty,make suretospecifylocalhostforthehostname and port2201toconnectto.From iOS/Linux:–Forsshuse:ssh-J<username>@canal.cs.nott.ac.uk:2222<username>@bann–Forscpuse:scp-J<username>@canal.cs.nott.ac.uk:2222file.c<username>@bann:Thiswillcopyfile.ctoyourroothome directory.TheH:drivewhere you storeyourcode isshared withtheservers.Any codewritteninan editorsuchasNotepad++orVisualStudio,andstoredontheH:drive,willbeautomaticallyvisibleonbann,andcanbecompiledthereusingansshconnection.Important:You must testthatyou are able toconnect to the serversfrom home using ansshtunnelearlyinthetermsothatanyproblemscanberesolved.NotbeingabletoconnecttotheserverswillnotbeavalidgroundforECs.1.2.2GNU C-CompilerYour codemustcompile and run onbann.cs.nott.ac.uk.Your submission will be tested and markedon thismachine,andwe cannotaccountforpotentialdiferenceswithotherconfigurations.You can compile your code with the GNU C-compiler using the commandgcc-std=gnu99<sources>,where<sources>isalistof Csourcefiles.Forexample:gcc-std=gnu99file1.cfile2.ccompilesanexecutablecalleda.outfromtwosourcefiles.Ifyouareusingpthreads,youmustaddtheflag-lpthreadwhen compiling.Forexample:gcc-std=gnu99file.c-lpthreadcompilesanexecutablecalleda.outfromonesourcefilewhichmightusethepthreadlibrary.Ifyouwanttospecifythenameoftheexecutablefile,extendyourcompilecommandwith-o<output>where<output>isyourchoiceof outputfilename.Forexample:gcc-std=gnu99file.c-oprog-lpthreadcompilesan executablecalledprogfromonesourcefilewhichmightusethepthreadlibrary.1.2.3GNU DebuggerCodeontheserverscanbedebuggedfromthecommandlineusing—gdb—,theGNU debugger.Tutorialson how tousethedebuggerareavailableonline.Seeforinstancehttps://www.cs.cmu.edu/~gilpin/tutorial/.