This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'virtual-memory-simulator/' from commit '9bce06bd3cd1fa93576c4861…
…2cd785d4b6eabddf' git-subtree-dir: virtual-memory-simulator git-subtree-mainline: 850114f git-subtree-split: 9bce06b
- Loading branch information
Showing
13 changed files
with
919 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Execute files | ||
fifo | ||
sc | ||
lru | ||
opt | ||
|
||
# Temporary files | ||
.dependency | ||
*.sh | ||
*.txt | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
.SUFFIXES: .c .o | ||
.PHONY: dep all new clean | ||
|
||
# Compiler | ||
CC = gcc | ||
# Compile option | ||
# -c: Generate object file | ||
# -W, -Wall: Print warning about all ambigous grammer | ||
# -Wextra: Print warning out of -W, -Wall | ||
# -O2: Optimization | ||
# -g: Debugging, PLEASE DELETE AFTER PROJECT COMPLETE! | ||
CFLAGS = -c -W -Wall -Wextra -g $(INCS) | ||
|
||
# Execute program file | ||
LRU = lru | ||
FIFO = fifo | ||
OPT = opt | ||
SC = sc | ||
|
||
# Source file | ||
COMMON_SRCS = common.c | ||
LRU_SRCS = lru.c | ||
FIFO_SRCS = fifo.c | ||
OPT_SRCS = opt.c | ||
SC_SRCS = sc.c | ||
SRCS = $(COMMON_SRCS) $(LRU_SRCS) $(FIFO_SRCS) $(OPT_SRCS) $(SC_SRCS) | ||
|
||
# Object file | ||
COMMON_OBJS = $(COMMON_SRCS:.c=.o) | ||
LRU_OBJS = $(LRU_SRCS:.c=.o) | ||
FIFO_OBJS = $(FIFO_SRCS:.c=.o) | ||
OPT_OBJS = $(OPT_SRCS:.c=.o) | ||
SC_OBJS = $(SC_SRCS:.c=.o) | ||
OBJS = $(COMMON_OBJS) $(LRU_OBJS) $(FIFO_OBJS) $(OPT_OBJS) $(SC_OBJS) | ||
# Library file | ||
LIBS = | ||
# Include path | ||
INCS = | ||
|
||
# Execute file grneration | ||
# $@ = TARGET | ||
# $^ = DEPENDENCY | ||
all : $(OBJS) | ||
$(CC) -o $(LRU) $(COMMON_OBJS) $(LRU_OBJS) $(LIBS) | ||
$(CC) -o $(FIFO) $(COMMON_OBJS) $(FIFO_OBJS) $(LIBS) | ||
$(CC) -o $(OPT) $(COMMON_OBJS) $(OPT_OBJS) $(LIBS) | ||
$(CC) -o $(SC) $(COMMON_OBJS) $(SC_OBJS) $(LIBS) | ||
$(LRU) : $(LRU_OBJS) $(COMMON_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
$(FIFO) : $(FIFO_OBJS) $(COMMON_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
$(OPT) : $(OPT_OBJS) $(COMMON_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
$(SC) : $(SC_OBJS) $(COMMON_OBJS) | ||
$(CC) -o $@ $^ $(LIBS) | ||
|
||
# Object file generation | ||
# $(OBJS): | ||
# $(CC) $(CFLAGS) $(SRCS) | ||
# $(COMMON_OBJS): | ||
# $(CC) $(CFLAGS) $(COMMON_SRCS) | ||
# $(LRU_OBJS): | ||
# $(CC) $(CFLAGS) $(LRU_SRCS) | ||
# $(FIFO_OBJS): | ||
# $(CC) $(CFLAGS) $(FIFO_SRCS) | ||
# $(OPT_OBJS): | ||
# $(CC) $(CFLAGS) $(OPT_SRCS) | ||
# $(SC_OBJS): | ||
# $(CC) $(CFLAGS) $(SC_SRCS) | ||
|
||
# make dep: Make dependency information file | ||
dep: | ||
$(CC) -M $(INC) $(SRCS) > .dependency | ||
|
||
# make new: Re-generation | ||
new: | ||
$(MAKE) clean | ||
$(MAKE) all | ||
|
||
# make clean: Remove all generated file | ||
clean: | ||
rm *.o $(LRU) $(FIFO) $(OPT) $(SC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# Virtual Memory Paging Simulator | ||
|
||
가상메모리 관리 기법의 하나인 페이지 교체 기법 중 OPT, FIFO, LRU, Second-Chance를 구현하고 동작 과정을 보여주는 시뮬레이터 구현하기 | ||
|
||
## 0. Quick start | ||
|
||
``` bash | ||
$ git clone https://github.com/codejune/c-virtual-memory-simulator.git | ||
$ cd c-virtual-memory-simulator | ||
|
||
# 일괄 빌드 | ||
$ make | ||
|
||
# 개별 빌드 | ||
$ make opt | ||
$ ./opt | ||
``` | ||
|
||
## 1. Environment | ||
|
||
### Software | ||
|
||
- Ubuntu 20.04.3 LTS (x86_64) | ||
- Linux Kernel 5.11.22 | ||
|
||
### Hardware | ||
|
||
- VM Instance | ||
- 4 Core 8 Thread | ||
- 8 GB RAM | ||
- 60 GB Storage | ||
|
||
## 2. Requirement | ||
|
||
### 페이징 기법 단축어 | ||
|
||
- OPT: opt | ||
- FIFO: fifo | ||
- LRU: lru | ||
- Second-Chance: sc | ||
|
||
### 입력 | ||
|
||
- Page frame: min 1, max 4 | ||
- Page reference string: min 1, max 30 | ||
|
||
### 조건 | ||
|
||
- 실행 초기화면에서 입력 데이터의 파일 이름을 입력 받음 | ||
- 입력 데이터에는 Page frame 수, Page reference string 값 포함 | ||
- 각 기법간 Paging 과정 및 page fault 발생 출력 | ||
- Second-Chance 기법의 경우 참조 기록에 대한 주기적 Refresh는 없다고 가정 | ||
|
||
### 출력 | ||
|
||
- Input data | ||
|
||
``` bash | ||
$ cat input.txt | ||
3 # Page frame 수 | ||
2 3 2 1 5 2 4 5 3 2 5 2 # Page reference string | ||
``` | ||
|
||
- Output (OPT) | ||
|
||
``` bash | ||
$ ./opt | ||
Input file path > input.txt | ||
Used method : OPT | ||
Page frames: 3 | ||
Page reference string: 2 3 2 1 5 2 4 5 3 2 5 2 | ||
frame 1 2 3 page fault | ||
time | ||
1 2 F | ||
2 2 3 F | ||
3 2 3 | ||
4 2 3 1 F | ||
5 2 3 5 F | ||
6 2 3 5 | ||
7 4 3 5 F | ||
8 4 3 5 | ||
9 4 3 5 | ||
10 2 3 5 F | ||
11 2 3 5 | ||
12 2 3 5 | ||
Number of page faults: 6 times | ||
``` | ||
|
||
- Output (FIFO) | ||
|
||
``` bash | ||
$ ./fifo | ||
Input file path > input.txt | ||
Used method : FIFO | ||
Page frames: 3 | ||
Page reference string: 2 3 2 1 5 2 4 5 3 2 5 2 | ||
frame 1 2 3 page fault | ||
time | ||
1 2 F | ||
2 2 3 F | ||
3 2 3 | ||
4 2 3 1 F | ||
5 5 3 1 F | ||
6 5 2 1 F | ||
7 5 2 4 F | ||
8 5 2 4 | ||
9 3 2 4 F | ||
10 3 2 4 | ||
11 3 5 4 F | ||
12 3 5 2 F | ||
Number of page faults: 9 times | ||
``` | ||
|
||
- Output (LRU) | ||
|
||
``` bash | ||
$ ./lru | ||
Input file path > input.txt | ||
Used method : LRU | ||
Page frames: 3 | ||
Page reference string: 2 3 2 1 5 2 4 5 3 2 5 2 | ||
frame 1 2 3 page fault | ||
time | ||
1 2 F | ||
2 2 3 F | ||
3 2 3 | ||
4 2 3 1 F | ||
5 2 5 1 F | ||
6 2 5 1 | ||
7 2 5 4 F | ||
8 2 5 4 | ||
9 3 5 4 F | ||
10 3 5 2 F | ||
11 3 5 2 | ||
12 3 5 2 | ||
Number of page faults: 7 times | ||
``` | ||
|
||
- Output (Second-Chance) | ||
|
||
``` bash | ||
$ ./sc | ||
Input file path > input.txt | ||
Used method : SC | ||
Page frames: 3 | ||
Page reference string: 2 3 2 1 5 2 4 5 3 2 5 2 | ||
frame 1 2 3 page fault | ||
time | ||
1 2 F | ||
2 2 3 F | ||
3 2 3 | ||
4 2 3 1 F | ||
5 2 5 1 F | ||
6 2 5 1 | ||
7 2 5 4 F | ||
8 2 5 4 | ||
9 2 5 3 F | ||
10 2 5 3 | ||
11 2 5 3 | ||
12 2 5 3 | ||
Number of page faults: 6 times | ||
``` |
Oops, something went wrong.