-
[OS] 14. CheckpointOS/OS from Scratch 2021. 6. 28. 01:35
서론
이번 강의에서는 앞으로의 강의를 진행하기 위해 코드들을 reformat 하겠습니다. 해당 Github 강의는 다음과 같습니다.
https://github.com/cfenollosa/os-tutorial/tree/master/14-checkpoint
cfenollosa/os-tutorial
How to create an OS from scratch. Contribute to cfenollosa/os-tutorial development by creating an account on GitHub.
github.com
이론
Monolithic/Micro Kernel

https://en.wikipedia.org/wiki/Microkernel Monolithic Kernel은 애플리케이션을 제외한 모든 시스템 기능들이 커널의 각 영역에 들어가 있는 형태를 의미합니다. Linux Kernel이 Monolithic Kernel의 형태입니다.
반면 Micro Kernel은 Monolithic Kernel이 관리하던 시스템 기능들이 Kernel위에 서버의 형태로 존재하는 형태입니다. 이를 통해 하나의 시스템 서비스가 다운돼도 Kernel 전체에 문제가 생기지 않습니다. 대표적으로 OSX의 Darwin Kernel과 Windows의 Windows NT Kernel이 Micro Kernel입니다.
코드
Makefile
GDB 디버깅을 위해 Makefile이 수정되었습니다. 설명은 주석에 있습니다.
# kernel/<파일명>.c, drivers/<파일명>.c 파일들을 매칭 # 파일명들을 띄어쓰기로 구분된 문자열 생성 C_SOURCES = $(wildcard kernel/*.c drivers/*.c) HEADERS = $(wildcard kernel/*.h drivers/*.h) # C_SOURCES의 파일명에서 마지막 .c대신 .o으로 대체 OBJ = ${C_SOURCES:.c=.o} CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb # gcc의 flag CFLAGS = -g all: run os-image.bin: boot/bootsect.bin kernel.bin cat $^ > os-image.bin kernel.bin: boot/kernel_entry.o ${OBJ} i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary # 디버깅 위해 생성 kernel.elf: boot/kernel_entry.o ${OBJ} i386-elf-ld -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin debug: os-image.bin kernel.elf qemu-system-i386 -s -fda os-image.bin -S & ${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf" # %.o: %.c .o로 끝나는 파일와 동일한 파일명의 .c파일 %.o: %.c ${HEADERS} ${CC} ${CFLAGS} -ffreestanding -c $< -o $@ %.o: %.asm nasm $< -f elf -o $@ %.bin: %.asm nasm $< -f bin -o $@ clean: rm -rf *.bin *.dis *.o os-image.bin *.elf rm -rf kernel/*.o boot/*.bin drivers/*.o boot/*.o
실행 결과
make debug를 통해 GDB를 실행시킨 결과 GDB가 잘 작동하지 않았습니다. 이는 해당 Github 강좌의 Issue에도 언급된 문제이며 GDB 자체의 문제로 해결하기 어려운 것으로 생각됩니다.
'OS > OS from Scratch' 카테고리의 다른 글
[OS] 16. Video Driver (0) 2021.07.02 [OS] 15. Video Ports (0) 2021.06.30 [OS] 13. Kernel Barebones (0) 2021.06.27 [OS] 12. Kernel C (0) 2021.06.26 [OS] 11. Kernel Cross Compiler (0) 2021.06.23