Pintos ๊ฐ๋ฐ ํ๊ฒฝ ์์ ๊ฐ์ด๋
1. ์ค์น ์ ์ค๋น
โข
Linux ํ๊ฒฝ (์: Ubuntu 16.04 ์ด์) ๋๋ WSL2 (Windows์ ๊ฒฝ์ฐ)
โข
ํ
์คํธ ํ๊ฒฝ์ ๋ค์๊ณผ ๊ฐ์:
โฆ
Ubuntu 16.04.6 LTS
โฆ
gcc 7.4.0
โฆ
qemu-system-x86 2.5.0
2. Pintos ์์ค์ฝ๋ ๋ค์ด๋ก๋
git clone https://github.com/casys-kaist/pintos-kaist
cd pintos-kaist
Bash
๋ณต์ฌ
3. ๊ฐ๋ฐ ๋๊ตฌ ์ค์น (Ubuntu / WSL2 ๊ธฐ์ค)
sudo apt update
sudo apt install -y gcc make qemu-system-x86 python3
Bash
๋ณต์ฌ
โป gcc๋ 32๋นํธ ์ปดํ์ผ์ ์ํด multilib ํ์ํ ์ ์์:
sudo apt install gcc-multilib
Bash
๋ณต์ฌ
4. ํ๊ฒฝ ์ค์ ํ์ฑํ
Pintos ๋ฃจํธ ๋๋ ํ ๋ฆฌ์์ ์๋ ๋ช
๋ น ์คํ:
source ./activate
Bash
๋ณต์ฌ
์ด ๋ช
๋ น์ ๋ค์์ ์๋์ผ๋ก ์ค์ ํด์ค๋๋ค:
โข
PATH ๋ฑ๋ก
โข
Makefile ๋์์ ์ํ ํ๊ฒฝ๋ณ์
5. ๋งค๋ฒ ์๋์ผ๋ก ํ์ฑํํ๋ ค๋ฉด .bashrc์ ์ถ๊ฐ
cd ~
code .bashrc # VSCode๋ก ํธ์ง
Bash
๋ณต์ฌ
๋ค์ ๋ผ์ธ์ ๊ฐ์ฅ ์๋์ ์ถ๊ฐ:
# command for logging in
source ~/pintos-kaist/activate
Bash
๋ณต์ฌ
๋ณ๊ฒฝ ํ ํฐ๋ฏธ๋ ์ฌ์์ ๋๋ ์๋ ๋ช
๋ น์ผ๋ก ์ ์ฉ:
source ~/.bashrc
Bash
๋ณต์ฌ
์ด์ Pintos ์ค์ต์ ์์ํ ์ค๋น๊ฐ ์๋ฃ๋์์ต๋๋ค!
์ง๊ธ๋ถํฐ๋ WSL์ Pintos ๊ฐ๋ฐํ๊ฒฝ์ VSCode๋ก ์ฐ๋ํด์ ํธํ๊ฒ ์์
ํ ์ ์๋๋ก ํด๋๋ฆด๊ฒ์.
Windows + WSL + VSCode ์กฐํฉ์ Pintos ๊ฐ๋ฐ์ ์์ฃผ ์ข์ต๋๋ค.
1. VSCode์ WSL ํ์ฅ ์ค์น
1.
VSCode ์คํ
2.
์ข์ธก ์ฌ์ด๋๋ฐ์์ Extensions (ํ์ฅ) ํด๋ฆญ
3.
๊ฒ์์ฐฝ์ Remote - WSL ์
๋ ฅ
4.
Microsoft์์ ๋ง๋ Remote - WSL ํ์ฅ ์ค์น
ํ์ฅ ID: ms-vscode-remote.remote-wsl
2. WSL ํ๊ฒฝ์์ VSCode ์ด๊ธฐ
๋ฐฉ๋ฒ A. WSL ํฐ๋ฏธ๋์์ VSCode ์คํ
WSL Ubuntu ํฐ๋ฏธ๋์ ์๋ ์
๋ ฅ:
cd /mnt/d/Github/pintos-kaist #๋ณธ์ธ ์ค์น ๊ฒฝ๋ก
code .
Bash
๋ณต์ฌ
code . ๋ช
๋ น์ด ์คํ๋๋ฉด, ํ์ฌ ๋๋ ํ ๋ฆฌ๊ฐ VSCode์์ ์ด๋ฆฌ๋ฉฐ WSL ์ฐ๋๋ ์ฐฝ์ด ๋น๋๋ค.
์๋จ์ [WSL: Ubuntu] ํ์๊ฐ ๋ณด์ด๋ฉด ์ฑ๊ณต์
๋๋ค.
3. VSCode ์ค์ ์ถ์ฒ
settings.json (์ ํ์ฌํญ)
.vscode/settings.json ํ์ผ์ ํ๋ก์ ํธ ๋ฃจํธ์ ๋ง๋ค์ด ์๋ ๋ด์ฉ ์ถ๊ฐ:
{
"terminal.integrated.defaultProfile.linux": "bash",
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
"files.associations": {
"*.h": "c"
}
}
JSON
๋ณต์ฌ
Makefile ๊ธฐ๋ฐ ํ๋ก์ ํธ๋ฅผ ์ํ ์ค์ ์
๋๋ค.
4. C/C++ ํ์ฅ๋ ์ค์น
1.
VSCode ํ์ฅ ํญ์์ C/C++ ๊ฒ์
2.
Microsoft์์ ๋ง๋ ํ์ฅ ์ค์น
ํ์ฅ ID: ms-vscode.cpptools
5. ๋น๋/์คํ์ ํฐ๋ฏธ๋์์
โข
VSCode ๋ด์์ Ctrl + ~ ํค ๋๋ฌ ํฐ๋ฏธ๋ ์ด๊ณ ,
โข
Pintos ๋๋ ํ ๋ฆฌ์์ ์์
:
cd threads # cd = change directory (๋๋ ํ ๋ฆฌ ์ด๋)
make # ์ปค๋ ๋น๋
make check # ํ
์คํธ ์คํ
# ์์ ๊ฒฐ๊ณผ:
# 20 of 27 tests failed. (โ ํ
์คํธ ํต๊ณผ์จ์ ์ฒดํฌํ๊ธฐ ์ํด ๋์ค๋ ๋ฉ์์ง)
Bash
๋ณต์ฌ
๋น๋๊ฐ ์๋ฃ๋ ํ, build ๋๋ ํ ๋ฆฌ์์ ์ฃผ๋ชฉํ ๋งํ ์ฃผ์ ํ์ผ๋ค์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค
โข
Makefile
โข
kernel.bin
kernel.o์์ ๋๋ฒ๊น
์ ๋ณด๋ฅผ ์ ๊ฑฐํ ๋ฒ์ ์ด๋ฉฐ, ๊ณต๊ฐ์ ์ ์ฝํ์ฌ ์ปค๋ ๋ก๋๊ฐ ๊ฐ์ ํ๋ 512kB ์ ํ์ ๋์ง ์๋๋ก ํด์ค๋๋ค.
โข
loader.bin
์ด๋ ๋์คํฌ๋ก๋ถํฐ ์ปค๋์ ๋ฉ๋ชจ๋ฆฌ๋ก ๋ถ๋ฌ์ค๊ณ ์คํ์ ์์ํ๋ ์์ฃผ ์งง์ ์ด์
๋ธ๋ฆฌ ์ฝ๋์
๋๋ค.
PC BIOS์ ์ ์ฝ์ผ๋ก ์ ํํ 512๋ฐ์ดํธ ํฌ๊ธฐ๋ก ๋์ด ์์ต๋๋ค.
โข
ํ์ ๋๋ ํ ๋ฆฌ๋ค (build/ ๋ด๋ถ)
.d ํ์ผ์ ์ด๋ค ํค๋ ํ์ผ์ด ๋ฐ๋์์ ๋ ์ด๋ค .c ํ์ผ์ ๋ค์ ์ปดํ์ผํด์ผ ํ๋์ง๋ฅผ make์๊ฒ ์๋ ค์ฃผ๋ ์ญํ ์ ํฉ๋๋ค.
๋๋ฒ๊น ํ๋ ๋ฐฉ๋ฒ
Source Tree Overview โ ์์ค ํธ๋ฆฌ ๋๋ฌ๋ณด๊ธฐ
Let's take a look at what's inside. Here's the directory structure that you should see inย pintos/
โข
threads/
โข
userprog/
โข
vm/
โข
filesys/
โข
devices/
Project 1์์๋ ํ์ด๋จธ ์ฝ๋๋ฅผ ์์ ํ๊ฒ ๋๋ฉฐ, ๊ทธ ์ธ์ ๋ถ๋ถ์ ๋๋ถ๋ถ ์์ ํ์ง ์์๋ ๋ฉ๋๋ค.
โข
lib/
โข
include/lib/kernel/
์: ๋นํธ๋งต(bitmap), ์ด์ค ์ฐ๊ฒฐ ๋ฆฌ์คํธ, ํด์ ํ
์ด๋ธ ๋ฑ ์ปค๋ ์ฝ๋์์ ์์ ๋กญ๊ฒ ์ฌ์ฉ ๊ฐ๋ฅํ ์๋ฃ๊ตฌ์กฐ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
์ปค๋์์๋ #include <...> ๋ฌธ๋ฒ์ผ๋ก ์ด ๋๋ ํ ๋ฆฌ์ ํค๋๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
โข
include/lib/user/
์ ์ ์ฝ๋์์๋ ๋ง์ฐฌ๊ฐ์ง๋ก #include <...> ํ์์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
โข
tests/
ํ
์คํธ ํธ์๋ฅผ ์ํด ์์ ํด๋ ๋์ง๋ง, ์ต์ข
์ฑ์ ์์๋ ์๋ ์ฝ๋๋ก ๊ต์ฒด๋์ด ํ
์คํธ๋ฉ๋๋ค.
โข
examples/
โข
include/
Running Pintos โ Pintos ์คํํ๊ธฐ
We've supplied a program for conveniently running Pintos in a simulator, called pintos. In the simplest case, you can invoke pintos as pintos argument.... Each argument is passed to the Pintos kernel for it to act on.
๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ํํ๋ก pintos argument...์ ๊ฐ์ด ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด, ํด๋น argument๋ค์ด Pintos ์ปค๋๋ก ์ ๋ฌ๋์ด ๋์ํ๊ฒ ๋ฉ๋๋ค.
Try it out. First cd into the newly created build directory. Then issue the command pintos run alarm-multiple, which passes the arguments run alarm-multiple to the Pintos kernel.
pintos run alarm-multiple
Bash
๋ณต์ฌ
์ด ๋ช
๋ น์ run๊ณผ alarm-multiple์ด๋ผ๋ ๋ ๊ฐ์ ์ธ์๋ฅผ Pintos ์ปค๋๋ก ์ ๋ฌํฉ๋๋ค.
(run์ ํ
์คํธ๋ฅผ ์คํํ๋ผ๋ ์๋ฏธ์ด๊ณ , alarm-multiple์ ์คํํ ํ
์คํธ ์ด๋ฆ์
๋๋ค.)
In these arguments, run instructs the kernel to run a test and alarm-multiple is the test to run. Pintos boots and runs the alarm-multiple test program, which outputs a few screenfuls of text.
Pintos๋ ๋ถํ
๋ ํ alarm-multiple ํ
์คํธ ํ๋ก๊ทธ๋จ์ ์คํํ๋ฉฐ, ๊ฒฐ๊ณผ๋ก ์ฌ๋ฌ ์ค์ ์ถ๋ ฅ ๋ฉ์์ง๋ฅผ ๋ณด์ฌ์ค๋๋ค.
You can log serial output to a file by redirecting at the command line, e.g. pintos -- run alarm-multiple > logfile. The pintos program offers several options for configuring QEMU or the virtual hardware.
pintos -- run alarm-multiple > logfile
Bash
๋ณต์ฌ
์ด๋ ๊ฒ ํ๋ฉด serial output์ด logfile์ ๊ธฐ๋ก๋ฉ๋๋ค.
๋ํ, pintos๋ QEMU๋ ๊ฐ์ ํ๋์จ์ด ์ค์ ์ ์ํ ์ฌ๋ฌ ์ต์
๋ค์ ์ ๊ณตํฉ๋๋ค.
If you specify any options, they must precede the commands passed to the Pintos kernel and be separated from them by --, so that the whole command looks like pintos option... -- argument..... Invoke pintos without any arguments to see a list of available options.
์ ์ฒด ๋ช
๋ น์ด ํ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
pintos [์ต์
๋ค] -- [์ปค๋์ ์ ๋ฌํ ์ธ์๋ค]
Bash
๋ณต์ฌ
์๋ฅผ ๋ค์ด, ์๋๋ QEMU์ VGA ์ถ๋ ฅ์ ๋๊ณ ์ปค๋์ run alarm-multiple์ ์ ๋ฌํ๋ ๋ช
๋ น์
๋๋ค:
pintos -v -- run alarm-multiple
Bash
๋ณต์ฌ
Options includes: how you want VM output to be displayed: use -v to turn off the VGA display, or -s to suppress serial input from stdin and output to stdout. The Pintos kernel has commands and options other than run. These are not very interesting for now, but you can see a list of them using -h, e.g. pintos -h.
โข
v: VGA ๋์คํ๋ ์ด๋ฅผ ๋๋๋ค (๊ทธ๋ํฝ ์ฐฝ ์์ด ์คํ๋จ)
โข
s: stdin/stdout์ ์
์ถ๋ ฅ์ ๋ง์ต๋๋ค (serial ์
์ถ๋ ฅ ์ฌ์ฉ ์ ์ ์ฉ)
โข
h: ์ฌ์ฉ ๊ฐ๋ฅํ ์ปค๋งจ๋์ ์ต์
๋ค์ ๋์ดํฉ๋๋ค
pintos -h
Bash
๋ณต์ฌ
ํ์ํ๋ค๋ฉด ์ค์ alarm-multiple์ด ์ด๋ค ๋์์ ์ํํ๋์ง, QEMU์์ ์ด๋ค ๋ฐฉ์์ผ๋ก ์คํ๋๊ณ ์ถ๋ ฅ์ด ํ๋ฅด๋์ง๋ ์ค๋ช
ํด๋๋ฆด ์ ์์ต๋๋ค. ์ํ์๋ฉด ์๋ ค์ฃผ์ธ์!