project 0. introduction of xv6csl.skku.edu/uploads/sse3044s19/project0.pdf · 2019-03-13 ·...
TRANSCRIPT
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected])
SSE3044 Introduction to Operating Systems
Prof. Jinkyu Jeong
Project 0. Introduction of xv62019.3.13 (Wed.)
TA)
이규선([email protected])
송원석([email protected])
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 2
Project plan
▪ Total 5 projects
0) Booting xv6 operating system
1) System call
2) CPU scheduling
3) Virtual memory
4) Page replacement
5) File systems
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 3
Project plan
▪ Total 5 projects
0) Booting xv6 operating system
1) System call
2) CPU scheduling
3) Virtual memory
4) Page replacement
5) File systems
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 4
Operating System
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 5
Operating System
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 6
xv6 Operating System
▪ Unix-like teaching operating system developed by MIT
▪ Based on multiprocessor x86 system
xv6 shell status with ls command
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 7
Version Control System (VCS)
• Manage changes of documents, computer
programs, and other collections of information
Centralized revision control system Distributed revision control system
server
version
database
version 1
version 2
version 3
user A
user B
file
file
checkout
checkout
user A
version
database
version 1
version 2
version 3
user B
version
database
version 1
version 2
version 3
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 8
Work flow on local repository
Initialize
repository
Create or add
files
Modify filesCommit files
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 9
Install & Setup
• Install
– Linux : sudo apt-get install git
– Windows, Mac : download at http://git-scm.com/
• User setup
– $ git config --global user.name <name>
– $ git config --global user.email <e-mail>
– $ git config –global core.editor vim
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 10
Git Basic Commands
– $ git init
• Create an empty Git repository or reinitialize an existing one
– $ git add <filename>
• Add file contents to the index
– $ git rm <filename>
• Remove files from the working tree and from the index
– $ git commit
• Record changes to the repository
• options
– -a : Tell the command to automatically stage files that have been modified
– -m “<msg>” : Use the given “msg” as the commit message
– $ git status
• Show the working tree status
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 11
Add File to Git Local Repository
• Example
– $ vi name.txt / vi current_time.txt
– $ git status
– $ git add –A ($ git add --help)
– $ git status
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 12
Add File to Git Local Repository
– $ git commit ($ git commit –m “<message>”)
– $ git config --global core.editor vim
– $ git commit
– $ vi current_time.txt and update time
– $ git status / $ git commit
– $ git add –u / $ git commit –m “current_time updated”)
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 13
Git Branch Command
– $ git branch
• List, create, or delete branches
• Options
– [-d] <branchname> : The name of the branch to create or delete
A B C E
D
master
test
$ git branch test
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 14
Git Branch Command
– $ git checkout
• Checkout a branch or paths to the working tree
• Options
– <branchname> : switch to “branchname”
– -b <newbranch> : create “newbranch” and switch
git checkout test
A B C E
D
master
test
6a7b34...
git checkout 6a7b34
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 15
Git Branch Command
– $ git merge
• Join two or more development histories together
• Options
– <branchname> : Reply the changes of “branchname” on top of current branch
git merge topic
B C E
D
master
topic
F
G
H
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 16
Conflictmaster topic
#include <iostream>
using namespace std;
int main(void) {
cout << “Hello!” << endl;
cout << “Master!” << endl;
}
#include <iostream>
using namespace std;
int main(void) {
cout << “Hello!” << endl;
cout << “Topic!” << endl;
}
#include <iostream>
using namespace std;
int main(void) {
cout << “Hello!” << endl;
<<<<<<< HEAD
cout << “Master!” << endl;
=======
cout << “Topic!” << endl;
>>>>>>> topic
}
git merge topic
Fix conflict and commit
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 17
Git Branch Command
– $ git rebase
• Forward-port local commits to the updated upstream head
• Options
– git rebase <upstream>
– git rebase <upstream> <branch>
– git rebase –onto <newbase> <upstream> <branch>
git rebase master | git rebase master test
B C E
D
master
test
F
G
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 18
Work flow on local repository
Create or add
files
Modify filesCommit files
Make
new-branch
Checkout
new-branch
Checkout
master branch
Merge master
& new-branch
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 19
.gitignore
• Ignore auxiliary files such as logs, input/out data, etc
• Generate automatically at https://www.gitignore.io/
cd ~/folder $ git add .gitignore
cd ~/folder $ git commit –m “added ‘.gitignore’ file”
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 20
Git Log Command
– $ git log
• Show commit logs
• Options
– -p : Show all changes at each commit
– --stat : Show statistics about modified files at each commit
– --name-only : Show only modified file name at each commit
– --relative-date : Show commit log with relative date
– --graph : Draw a text-based graphical representation of the commit history
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 21
GitHub
• Remote repository (place of co-work)
• Sign up for GitHub
– https://github.com
• Public repository for free user
• Functions
– Fork : Copy other user’s repository
– Pull requests : Communication with users
– Issues : Discuss issues between users in repository
– Wiki : Create a structured record of repository
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 22
GitHub Basic Command
– $ git clone
• Copy remote repository to local repository
~/git_tutorial git clone https://github.com/jquery/jquery.git
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 23
GitHub Basic Command
– $ git remote
• Link local repository and remote repository
• Options
– -v : Check the connection with local and remote repository
– add “name” “url” : Add a remote named “name” for the repository at “url”
– $ git push
• Push local repository contests to remote repository
• Options
– <repository> : destination (name or url)
– --all : push all modified contents in local repository
– $ git diff
• Show changes between local and remote
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 24
GitHub Basic Command
– $ git fetch
• Fetch contents from remote repository
• Options
– <repository> : name or url of remote repository
– --all : Fetch all contents from remote repository
Local repository Remote repository (GitHub)
Modified by other user
Commit
Push (fail)
fetch
merge
Push (success)
Updated by me
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 25
GitHub Basic Command
– $ git pull
• Fetch and integrate contents from remote repository
• Options
– <repository> : name or url of remote repository
– --all : Fetch all contents from remote repository
Local repository Remote repository (GitHub)
Modified by other user
Commit
Push (fail)
Pull
Push (success)
Updated by me
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 26
How to Write a Git Commit Message
1. Separate subject from body with a blank line
2. Limit the subject line to 50 characters
3. Capitalize the subject line
4. Do not end the subject line with a period
5. Use the imperative mood in the subject line
6. Wrap the body at 72 characters
7. Use the body to explain what and why vs. how
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 27
Reference
• Pro Git 2nd Edition
– https://git-scm.com/book/en/v2
• How to write a git commit message
– https://chris.beams.io/posts/git-commit/
• Command “git –help”
– ex) git checkout --help
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 28
Clone xv6
• $ git clone <repository>
– $ git clone https://github.com/tlsghkrnfla/xv6-sse3044.git
• $ cd xv6-sse3044 / $ git remote –v
• $ git remote set-url origin <your repository url>
• $ git pull
• $ git add –A / $ git commit -m “<message>” / $ git
push
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 29
Booting xv6
• Install qemu emulator
– $ sudo apt-get install qemu
• Run xv6
– $ cd xv6-sse3044
– $ make qemu-nox
• Terminate xv6
– ctrl + ‘a’ → ‘x’
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 30
Project 0. Booting xv6
▪ Follow the instructions on slides
▪ Print your student id, name, and any
message(optional)
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 31
Submission
• Send your file to TAs’ e-mail (both)
– $ make dist
– $ make dist-test
– $ make tar
• PLEASE DO NOT COPY
– YOU WILL GET F GRADE IF YOU COPIED
• Due date: 3/19(Tue.), 23:59:59 PM
– -25% per day for delayed submission
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 32
Questions
• If you have questions, please e-mail to TA
• You can also visit Semiconductor Building
#400509
– Please e-mail TA before visiting
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 33
Appendix. ctags & grep
• Install ctags– $sudo apt install ctags
• Vim setting for ctags– $ctags –R (where you will use)
– $vi ~/.vimrc
– Add “set tags=[Location of tag file]/tags”
– $source ~/.vimrc
• Ctags usage– ctrl + ] : follow tag
– ctrl + t : back to last tag
• Grep Usage– grep –nR “[string to search]”
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 34
Appendix. cscope
• Install cscope
– $sudo apt-get install cscope
• cscope database creation
– $find . \( -name '*.c' -o -name '*.h' -o -name '*.s' -o -name '*.S' \) -print > cscope.files
• start cscope
– $cscope →cscope starts(cscope.out created)– $ctrl + d : for termination
• using cscope in vi
1) add cscope database to vi
– $vi ~/.vimrc
– $cs add /...path.../cscope.out
2) searching using cscope in vi
– $:cs find s fork (in vi)
+) additionally,
– $:cn (next search), $:cp (previous search)
SSE3044: Operating System, Spring 2019, Jinkyu Jeong ([email protected]) 35
Appendix. vi instructions
** $sudo apt install vim
① vi [filename] -> Open file
② i -> keyboard typing mode
③ esc + :w -> save file
④ esc + :q -> exit file (esc + :wq -> save and exit)
⑤ /[string] -> search [string]
⑥ u -> back to last command
⑦ :vs -> open additional file on same session
⑧ dd -> erase one line
⑨ :set mouse=a -> activate mouse
① Drag and y -> copy multi-line
② p -> paste
* Reference: http://www.antsys.co.kr/data/vi_editor.htm