os final project
TRANSCRIPT
![Page 1: Os final project](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/1.jpg)
C-ShellMark and Turner
![Page 2: Os final project](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/2.jpg)
Patterns
• Reactor
• Singleton
• Interpreter
• Factory
• Builder
![Page 3: Os final project](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/3.jpg)
Shell Reactor
• main function
• while loop, terminates when user enters “exit”
• Sends user input command to parser
![Page 4: Os final project](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.net/reader034/viewer/2022051123/58aad9f01a28ab27178b528d/html5/thumbnails/10.jpg)
Demonstration