Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 ....
Transcript of Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 ....
![Page 1: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/1.jpg)
Project #1: Command-Line User Interface Shell
and Utilities
![Page 2: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/2.jpg)
Outline
• Background
• General Requirements/Assumptions
• Implementation Tools
• Details
• Questions
![Page 3: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/3.jpg)
Operating Systems
• Provides resources and services
– Examples
• High-level interactions with user
• Protection mechanisms (e.g., process model)
• Processor scheduling
• Synchronization (Serialization) of executing code
• Filesystem
Project #1
Project #2
Project #3
![Page 4: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/4.jpg)
OS
Base System
inp
ut
ou
tpu
t
HW
![Page 5: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/5.jpg)
Command-Line Shell
• Provides means for user to interact with OS
– View/modify state of the system
• Simple and easy to use
• Considered a component of the OS
![Page 6: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/6.jpg)
Requirements
• User prompt • “built-in” utilities (Execute utility directly without
searching for it) – cd – ioacct – exit
• Start the execution of programs – background
• I/O redirection • input • output • pipelining
![Page 7: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/7.jpg)
Assumptions/Requirements
• Program written in C
• Makefile to build program
• No zombie processes
• No memory leaks
![Page 8: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/8.jpg)
IMPLEMENTATION TOOLS
![Page 9: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/9.jpg)
gcc Compiler
• Warnings are your friend and you don’t ignore your friends (most of the time)
• Useful gcc options – Wall
– Wextra
– pedantic
– Wconversion
– Wshadow
– std=c11 or -std=c99
![Page 10: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/10.jpg)
Makefile
• Targets – Name of file
– Name of an action
• Prerequisites – File/action that target depends on
– E.g., Source code files to create executable
• Recipe – Actions to create target file or satisfy named
action
target(s) : dependency(ies)
<tab>recipe
...
![Page 11: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/11.jpg)
PROJECT DETAILS
![Page 12: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/12.jpg)
Prompt
<username>@<hostname>:<working_directory> $
Example:
cop4610t@linprog:/home/grads/cop4610t $
![Page 13: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/13.jpg)
I/O Redirection
Text Terminal
Process
Keyboard
Display
![Page 14: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/14.jpg)
I/O Redirection
Text Terminal
Process
Keyboard
Display
FILEA
FILEB
![Page 15: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/15.jpg)
Redirect
FILEA open()
returns file descriptor
STDOUT_FILENO Process
dup2(fd_A, STDOUT…)
Display
fd_A
![Page 16: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/16.jpg)
File Descriptors
Kernel
File Descriptor Table (per-process)
ptr to terminal i/p
pointer to file A
ptr to terminal o/p
pointer to file A
<empty>
![Page 17: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/17.jpg)
File Descriptors
File Descriptor Table (per-process)
ptr to terminal i/p
pointer to file A
ptr to terminal o/p
pointer to file A
<empty>
Kernel Open File Table
# Off-set … inode
![Page 18: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/18.jpg)
Protection
Kernel Space
User Space
dup2()
![Page 19: Project #1: Command-Line User Interface Shell and Utilities · Project #1 Project #2 Project #3 . OS Base System t put HW . Command-Line Shell ... B . Redirect FILE A open() returns](https://reader035.fdocuments.us/reader035/viewer/2022081600/6047bd916250db432444c0cc/html5/thumbnails/19.jpg)
QUESTIONS?