Os final project

10
C-Shell Mark and Turner

Transcript of Os final project

Page 1: Os final project

C-ShellMark and Turner

Page 2: Os final project

Patterns

• Reactor

• Singleton

• Interpreter

• Factory

• Builder

Page 3: Os final project

Shell Reactor

• main function

• while loop, terminates when user enters “exit”

• Sends user input command to parser

Page 4: Os final project

ShellParser• Splits up each word in the

passed string based off of “ “ character.

• Pushes into a vector of strings.

• Also controls things such whether process will run in background, piping, output.

• Creates a new job from command.

• T

Page 5: Os final project

Job

• Factory

• makeJob() makes a new process from the commands

• launch() launches the process in job once they are made

• Job sets up piping for multiple process

Page 6: Os final project

Process

• With each process, a new process object is created.

• The process is then forked and exec’ed

• Output is printed to terminal

Page 7: Os final project

Shell

• Singleton Pattern- only one instance

• Holds a lot of the variables we need to keep global such as our command vector and terminal process id

• Mostly consists of accessor methods

Page 8: Os final project

Shell Commands• ls - lists all files in the directory

• cd - changes directory

• dirs - outputs current directory path

• exec - execs a process, then quits

• wait - waits for a process to finish based off of its pid

• help - displays a small help menu with valid commands

Page 9: Os final project

Some Challenges

• Piping- it took some time to figure out job management that allowed us to pipe.

• Parsing Special Characters- size_t overflow due to npos being values as “-1”

• Testing- Finding good use cases to test each feature as it was implemented.

Page 10: Os final project

Demonstration