EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
C语言代做
您的位置: 主页 > 编程案例 > C语言代做 >
代做C语言:C programs writing help Assignment 2 - C语言代做
发布时间:2021-07-25 20:12:23浏览次数:
Due 11:59pm, Monday May 13Detailed handin instructions at end of specification.This assignment is worth 15% of your marks for this course.For this prac you will write two C programs to execute a list of commands. Your first program will simply read in the commands and then execute them in a sequence. The second program will execute the commands in a pipeline, where the output of each command becomes the input to the next command in the sequence:cmd1 | cmd2 | cmd3 ………… | cmdnRound 1: sequence.cThis program should read and execute a list of commands from stdin. Each command and its arguments (if any) will appear on a separate line. For example, if the file cmdfile contains the lines:whoamical 4 2019echo The time is:datethen running./sequence cmdfileshould output your username, a calendar of the month of April, the string The time is: , and the current date/time, to standard output.Suggested approach: first, make sure you can parse a command and its arguments correctly, and store them as an array of C strings. Test this thoroughly before moving on, making use of trace statements to make sure you ve accounted for all the cases you can come up with! Debugging processes and pipes can be tricky so you want to have confidence you are giving later parts of your program the correct input. For the purposes of this prac, you can assume a maximum of 10 arguments per command, 256 characters per line, and 100 lines per file.Second, look at the exec() family of functions and use one to execute each command in turn. Hint: there is a sample program from the first lecture on processes that does something very similar! Here is a pseudo-code version of the setup:while there are remaining commands:read line from fileparse line into command and argumentsfor cmd in commands:fork and handle errorsif (child)execute commandelse // parentwait for child to terminateRound 2: pipeline.cThis program takes the same input as sequence.c, but executes the commands as a pipeline, where the output of each command is piped to the input of the next command in line. The input of the first command, and the output of the final command, should not be altered. For example, if the file cmdpipe contains the linesls -s1sort -ntail -n 5then running./pipeline cmdpipeshould output the 5 largest files in the current directory, in order of size.Suggested approach: set it up so that the parent process forks a child to execute each command in turn, and keeps track of the pipes that the current child should read from and write to. The child redirects its input and output to these pipes, and then executes the current command. Here is a pseudo-code version of the setup:// For each command except the final one:// new_pipe = the output of the current command// For each command except the first one:// prev_pipe = the output of the previous command, input of current commandfor cmd in cmds:if this is not the final command:pipe (new_pipe) // Create a new pipefork and handle errorsif (child)if this is not the first command:Redirect input to prev_pipeif this is not the final command:Redirect output to new_pipeexecute commandelse // parentif this is not the first command:close prev_pipeif this is not the final command:prev_pipe = new_pipeclose any remaining pipes, clean upRemember that once you call fork, both parent and child have their own copy of all variables, including pipes! Have a look at the pattern for setting up processes to read and write from pipes, from lectures.Make sure you close all pipes when they are no longer needed as not doing so can cause behaviour that is hard to debug.Note your code should work with any command. For example:calcat pipeline.cgrep .wc -lshould print out the number of non-blank lines in your source file (the first line has no effect why?).Submisison InstructionsThe handin key for this exercise is: prac2. The following SVN commands will enable you to make a repository for this assignment. Please note the following:• Perform these steps in the order written once only!• Replace aaaaaa, where it appears in the commands, with YOUR student id.• Some commands are long — they must be typed on one line.Use the Unix “cd” command to change to the place where you want your exercise directory to be stored, then type these commands:svn mkdir parents -m spc prac2 start https://version-control.adelaide.edu.au/svn/a1aaaaaa/2019/s1/spc/prac2(creates this directory in your svn tree)svn co https://version-control.adelaide.edu.au/svn/a1aaaaaa/2019/s1/spc/prac2 .(checks out a working copy in your directory) You can now begin work.You can add a file to the repository by typing the commands:svn add NAME-OF-FILEsvn commit -m REASON-FOR-THE-COMMIT where “reason-for-the-commit” should be some brief text that explains why you changed the code since the last commit. Note that you only need to add a file once — after that, SVN will “know” it is in the repository. You are now ready to commence working on the exercise.The files you handin must include:Your C source files as specified above.A Makefile that will compile your C sources as specified above.Make sure you commit your files frequently, in case you have an accident. The University’s SVN repository is very reliable, and is backed up regularly — your computer probably is not Regular submission is also a good defence against plagiarism by others, since the submissions are dated. We will test the behaviour of your scripts using an automated tester. The tester is thorough, and will find places where your scripts do not work correctly. If it finds an error, it will offer a (vaguish) hint. You should also come up with your own tests, as we may add extra test cases when determining your final mark!Note that we reserve the right to deduct marks if your code does anything egregious or games the system to obtain marks.End of Instructions.

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。