COMP2211 Operating Systems

Operating Systems (COMP2211)
Coursework 1: Shell implementation
Submission You must submit your work to the appropriate submission point on Gradescope.
You should submit a single file called mysh.c, any other files you submit will be ignored and
will not be marked.
Deadline See Gradescope submission date
Weighting This piece of summative coursework is worth 25% of the module grade.
Learning outcomes In this coursework you will demonstrate:

  • An understanding of how processes are created by the operating system
  • An understanding of file descriptors and their relationship to pipes and redirection.
  • The ability to program components of an operating system.
    In this coursework you will implement a simple shell for the Xv6 Operating System. The shell will
    be implemented as a user space program. Before you attempt this coursework, ensure that you
    have completed the “Operating System Interface” and “Operating System Organisation” directed
    reading.
    You should provide your implementation in a new file called mysh.c. You may use any helper
    functions provided by the Xv6 kernel or user libraries. For each of the following items implement
    the feature into your shell, as you progress the features to implement become hard. Your
    implementation should not require you to modify any file other than mysh.c and Makefile.
    Here are some simple instructions to get you started:
  • To start with create a file in the user directory for the Xv6 operating system source code
    called mysh.c.
  • Insert the appropriate headers and a main function into your mysh.c.
  • Modify the Makefile to include your shell in the build process.
  • Test that your new executable is being included by running make qemu. You should be able
    to execute your new program by typing mysh at the command prompt.
    Continue to implement the following features.
  • Execute simple commands (5 Marks)
    Implement the execution of simple commands. Your shell should be able to:
  • Prompt the user for a command by printing “>>>” as a command prompt.
  • Execute a command inputted to the command prompt.
  • Loop indefinitely until the shell is exited.
  • Handle the “cd” command (this is a special case so will need to be handled separately to
    other commands, why?).
    1
  • Input/Output redirection (6 Marks)
    Implement Input/Output redirection. Your shell should be able to:
  • Handle two element redirections. For example,
    echo "Hello world" > foo, or
    cat < foo
  • Pipes (6 Marks)
    Implement Pipes. Your shell should be able to:
  • Handle two element pipelines. For example,
    ls | grep mysh, or cat README | grep github
  • Additional features (8 Marks)
    Implement the following advanced features:
  • Implement multi element pipelines. For example,
    ls | head -3 | tail -1
  • Implement non-trivial combinations of pipes and redirection. For example,
    ls | head -3 | tail -1 > myoutput
  • Implement the “;” operator that allows a list of shell commands to be given and executed
    sequentially.

你可能感兴趣的:(后端)