Split View: [운영체제] 20. 리눅스와 Windows 10 운영체제 비교
[운영체제] 20. 리눅스와 Windows 10 운영체제 비교
리눅스와 Windows 10 운영체제 비교
Linux와 Windows는 서로 다른 설계 철학을 가진 운영체제입니다. 이 글에서는 두 운영체제의 커널 아키텍처, 프로세스 관리, 메모리 관리, 파일 시스템 등을 비교하며, Windows Subsystem for Linux(WSL)도 살펴봅니다.
1. Linux 시스템 개요
Linux 커널 아키텍처
Linux는 모놀리식(monolithic) 커널을 기반으로 하되, 모듈(module) 시스템으로 유연성을 확보합니다.
┌───────────────────────────────────────────────┐
│ 사용자 공간 │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │ bash │ │ nginx│ │ gcc │ │ java │ │
│ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ │
│ │ │ │ │ │
│ └────────┴────────┴────────┘ │
│ │ 시스템 콜 인터페이스 │
├──────────────┴────────────────────────────────┤
│ 커널 공간 │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ 프로세스 관리 │ │
│ │ 스케줄러 │ 프로세스 생성 │ 시그널 │ │
│ ├─────────────────────────────────────────┤ │
│ │ 메모리 관리 │ │
│ │ 가상 메모리 │ 페이지 캐시 │ slab │ │
│ ├─────────────────────────────────────────┤ │
│ │ VFS (가상 파일 시스템) │ │
│ │ ext4 │ XFS │ Btrfs │ NFS │ tmpfs │ │
│ ├─────────────────────────────────────────┤ │
│ │ 네트워크 스택 │ │
│ │ TCP/IP │ 소켓 │ Netfilter │ eBPF │ │
│ ├─────────────────────────────────────────┤ │
│ │ 장치 드라이버 │ │
│ │ 블록 │ 문자 │ 네트워크 │ USB │ │
│ └─────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ 하드웨어 추상화 │ │
│ └─────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ 하드웨어 │
└───────────────────────────────────────────────┘
Linux 프로세스 관리
// Linux의 프로세스 구조 (task_struct 주요 필드)
struct task_struct {
volatile long state; // 프로세스 상태
int prio; // 우선순위
struct mm_struct *mm; // 메모리 정보
struct fs_struct *fs; // 파일 시스템 정보
struct files_struct *files; // 열린 파일 테이블
struct signal_struct *signal; // 시그널 정보
pid_t pid; // 프로세스 ID
pid_t tgid; // 스레드 그룹 ID
struct task_struct *parent; // 부모 프로세스
struct list_head children; // 자식 프로세스 목록
// ...
};
Linux 프로세스 상태:
┌─────────┐ fork() ┌─────────┐
│ 존재하지│────────→ │ READY │
│ 않음 │ │ (실행 │
└─────────┘ │ 가능) │
└────┬────┘
스케줄링 │ 선점
┌────┴────┐
│ RUNNING │
│ (실행중)│
└────┬────┘
I/O 대기│ │exit()
┌────┴──┐│
│SLEEPING││
│(대기중)││
└────────┘│
┌─────┴───┐
│ ZOMBIE │
│(종료됨) │ → wait() → 제거
└─────────┘
Linux 프로세스 스케줄러 (CFS)
CFS(Completely Fair Scheduler)는 가상 런타임을 기반으로 공정하게 CPU 시간을 분배합니다.
CFS 레드-블랙 트리:
(vruntime 기준 정렬)
B (vruntime=50)
╱ ╲
A (30) ╱ ╲ D (80)
╱ ╲
C (45) E (100)
→ 가장 왼쪽 노드 (A, vruntime=30)가 다음 실행 대상
→ 실행 후 A의 vruntime 증가 → 트리 재배치
→ O(log n) 삽입/삭제
Linux 메모리 관리
Linux 프로세스 가상 주소 공간 (64비트):
높은 주소
┌──────────────────────┐ 0xFFFFFFFF...
│ 커널 공간 │
│ (모든 프로세스 공유)│
├──────────────────────┤ 0x7FFF...
│ 스택 (↓ 성장) │
│ │
│ (빈 공간) │
│ │
│ mmap 영역 │ ← 공유 라이브러리, mmap
│ │
│ (빈 공간) │
│ │
│ 힙 (↑ 성장) │ ← malloc/brk
├──────────────────────┤
│ BSS (초기화안됨)│
├──────────────────────┤
│ 데이터 (초기화됨)│
├──────────────────────┤
│ 텍스트 (코드) │
└──────────────────────┘ 0x0000...
낮은 주소
Linux 파일 시스템 관리
# Linux에서 지원하는 주요 파일 시스템
# ext4 : 범용 (가장 널리 사용)
# XFS : 대용량 파일/고성능
# Btrfs : CoW, 스냅샷, 압축
# tmpfs : 메모리 기반 임시 파일 시스템
# procfs : 프로세스 정보 (/proc)
# sysfs : 장치/드라이버 정보 (/sys)
# 마운트된 파일 시스템 확인
df -hT
# Filesystem Type Size Used Avail Use% Mounted on
# /dev/sda1 ext4 100G 45G 50G 48% /
# tmpfs tmpfs 16G 0 16G 0% /dev/shm
Linux 커널 모듈
런타임에 커널 기능을 동적으로 추가/제거할 수 있습니다.
// 간단한 커널 모듈 예시
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Example");
MODULE_DESCRIPTION("Hello World Module");
static int __init hello_init(void) {
printk(KERN_INFO "Hello, Kernel Module!\n");
return 0;
}
static void __exit hello_exit(void) {
printk(KERN_INFO "Goodbye, Kernel Module!\n");
}
module_init(hello_init);
module_exit(hello_exit);
# 커널 모듈 관리 명령어
# 로드된 모듈 목록
lsmod
# 모듈 로드
sudo insmod hello.ko
# 모듈 언로드
sudo rmmod hello
# 의존성 자동 해결 로드
sudo modprobe module_name
# 모듈 정보 확인
modinfo module_name
2. Windows 10 시스템 개요
Windows 아키텍처
Windows는 하이브리드 커널 구조를 사용합니다.
┌───────────────────────────────────────────────┐
│ 사용자 모드 │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ 시스템 프로세스 │ │
│ │ 서비스 관리자 │ LSA │ Session Manager │ │
│ └────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ 서브시스템 │ │
│ │ Windows (Win32) │ POSIX │ WSL │ │
│ └────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ 환경 서브시스템 DLL │ │
│ │ ntdll.dll │ kernel32.dll │ user32.dll │ │
│ └────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ 커널 모드 │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ 실행 엔진 (Executive) │ │
│ │ Object Mgr │ Process Mgr │ Memory Mgr│ │
│ │ I/O Mgr │ Cache Mgr │ Security │ │
│ │ Config Mgr │ PnP Mgr │ Power Mgr │ │
│ ├────────────────────────────────────────┤ │
│ │ 커널 (Kernel) │ │
│ │ 스케줄링 │ 동기화 │ 인터럽트 처리 │ │
│ ├────────────────────────────────────────┤ │
│ │ HAL (하드웨어 추상화 계층) │ │
│ └────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ 장치 드라이버 │ │
│ └────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ 하드웨어 │
└───────────────────────────────────────────────┘
Windows 객체 관리자 (Object Manager)
Windows 커널은 거의 모든 자원을 객체로 관리합니다.
객체 관리자 네임스페이스:
\
├── Device
│ ├── HarddiskVolume1
│ ├── Tcp
│ └── Null
├── ObjectTypes
│ ├── Process
│ ├── Thread
│ ├── File
│ ├── Mutex
│ └── Semaphore
├── Sessions
│ └── 1
│ └── BaseNamedObjects
│ └── MyMutex
└── GLOBAL??
├── C: → Device\HarddiskVolume1
└── D: → Device\CdRom0
Windows 객체 구조:
┌─────────────────────────────────┐
│ 객체 헤더 │
│ - 이름 │
│ - 디렉토리 │
│ - 보안 디스크립터 │
│ - 참조 카운트 │
│ - 핸들 카운트 │
│ - 객체 타입 포인터 │
├─────────────────────────────────┤
│ 객체 본체 │
│ - 타입별 데이터 │
│ (프로세스, 스레드, 파일 등) │
└─────────────────────────────────┘
Windows 프로세스 및 스레드 관리
Windows 프로세스 구조:
┌─────────────────────────────────────┐
│ 프로세스 (EPROCESS) │
│ - 가상 주소 공간 │
│ - 핸들 테이블 (열린 객체) │
│ - 액세스 토큰 (보안 컨텍스트) │
│ - PID │
│ │
│ ┌─────────┐ ┌─────────┐ ┌────────┐ │
│ │Thread 1 │ │Thread 2 │ │Thread 3│ │
│ │(ETHREAD)│ │(ETHREAD)│ │(ETHREAD│ │
│ │- TEB │ │- TEB │ │- TEB │ │
│ │- 스택 │ │- 스택 │ │- 스택 │ │
│ │- 우선순위│ │- 우선순위│ │- 우선순위││
│ └─────────┘ └─────────┘ └────────┘ │
└─────────────────────────────────────┘
Windows 스케줄링
Windows 우선순위 수준:
31 ┌──────────────────┐
│ Real-time 클래스 │ 16-31: 실시간 우선순위
16 ├──────────────────┤
15 │ Variable 클래스 │ 1-15: 동적 우선순위
│ │ (I/O 완료 시 일시적 부스트)
1 ├──────────────────┤
0 │ Idle │ 0: 시스템 유휴 스레드
└──────────────────┘
우선순위 부스트:
- 대화형 프로세스: 전경 부스트
- I/O 완료: 임시 우선순위 상승
- 기아 방지: 장기 대기 스레드 부스트
Windows 메모리 관리자
Windows 가상 메모리 구조 (64비트):
높은 주소
┌──────────────────────┐
│ 커널 공간 │ (상위 절반)
│ - 커널 코드/데이터 │
│ - 페이지드/논페이지드│
│ 풀 │
├──────────────────────┤ 0x7FFF...
│ 사용자 공간 │ (하위 절반, 128TB)
│ - DLL │
│ - 힙 │
│ - 스택 │
│ - 실행 파일 이미지 │
└──────────────────────┘ 0x0000...
특수 메모리:
- Paged Pool: 페이지 아웃 가능한 커널 메모리
- NonPaged Pool: 항상 물리 메모리에 상주
- Section Object: 메모리 매핑 파일
NTFS (NT File System)
NTFS 주요 특징:
┌──────────────────────────────────────────┐
│ MFT (Master File Table): │
│ - 모든 파일/디렉토리의 메타데이터 저장 │
│ - 각 엔트리 약 1KB │
│ - 작은 파일은 MFT 레코드에 직접 저장 │
│ │
│ MFT 레코드 구조: │
│ ┌───────────────────────────────────┐ │
│ │ 헤더 │ │
│ ├───────────────────────────────────┤ │
│ │ Standard Information 속성 │ │
│ │ (타임스탬프, 플래그 등) │ │
│ ├───────────────────────────────────┤ │
│ │ File Name 속성 │ │
│ ├───────────────────────────────────┤ │
│ │ Data 속성 │ │
│ │ (작은 파일: 데이터 직접 저장) │ │
│ │ (큰 파일: 실행(run) 목록) │ │
│ ├───────────────────────────────────┤ │
│ │ Security Descriptor 속성 │ │
│ └───────────────────────────────────┘ │
│ │
│ 추가 특징: │
│ - 저널링 (트랜잭션 로그) │
│ - 파일 수준 압축 │
│ - 파일 수준 암호화 (EFS) │
│ - 대체 데이터 스트림 (ADS) │
│ - ACL 기반 세밀한 접근 제어 │
│ - 디스크 할당량 │
│ - 심볼릭 링크, 접합점(junction) │
└──────────────────────────────────────────┘
3. Linux vs Windows 비교
커널 아키텍처 비교
| 특성 | Linux | Windows |
|---|---|---|
| 커널 유형 | 모놀리식 (+ 모듈) | 하이브리드 |
| 소스 코드 | 오픈소스 (GPL) | 비공개 (일부 공개) |
| 장치 드라이버 | 커널 내/모듈 | 커널/사용자 모드 드라이버 |
| 파일 시스템 | VFS 추상화 | I/O 관리자 + 필터 드라이버 |
| 보안 모델 | DAC + MAC (SELinux) | ACL + 무결성 수준 |
프로세스 모델 비교
Linux: Windows:
┌─────────────────────┐ ┌─────────────────────┐
│ 프로세스 (fork) │ │ 프로세스 │
│ ┌────┐ │ │ (CreateProcess) │
│ │Task│ = 프로세스 │ │ ┌──────┐ ┌──────┐ │
│ └────┘ │ │ │Thread│ │Thread│ │
│ │ │ └──────┘ └──────┘ │
│ 스레드 = 경량 │ │ │
│ 프로세스 (clone) │ │ 파이버(Fiber): │
│ ┌────┐ ┌────┐ │ │ 사용자 모드 스레드 │
│ │Task│ │Task│ │ │ (협력적 스케줄링) │
│ └────┘ └────┘ │ └─────────────────────┘
│ → 같은 mm_struct │
│ 공유 (주소공간) │
└─────────────────────┘
Linux fork(): 프로세스 복제 (CoW)
Windows CreateProcess(): 새 프로세스 직접 생성
파일 시스템 비교
| 특성 | Linux (ext4) | Windows (NTFS) |
|---|---|---|
| 메타데이터 | inode | MFT 레코드 |
| 최대 파일 크기 | 16 TiB | 256 TiB |
| 저널링 | 지원 | 지원 |
| 권한 | POSIX (rwx) | ACL |
| 대소문자 | 구분 | 보존 (기본 미구분) |
| 파일 스트림 | 단일 | 다중 (ADS) |
| 암호화 | dm-crypt (볼륨) | EFS (파일 단위) |
IPC (프로세스 간 통신) 비교
Linux IPC: Windows IPC:
- pipe / named pipe (FIFO) - Named Pipes
- UNIX 도메인 소켓 - Mailslots
- System V IPC - Shared Memory (Section)
(shmem, semaphore, msgqueue) - COM / DCOM
- POSIX IPC - Windows Messages
- D-Bus - RPC
- netlink 소켓 - ALPC (Advanced Local
- io_uring Procedure Call)
4. Windows Subsystem for Linux (WSL)
WSL은 Windows에서 Linux 바이너리를 네이티브로 실행할 수 있게 합니다.
WSL 1 vs WSL 2
WSL 1:
┌──────────────────────────────────────┐
│ Linux 사용자 공간 │
│ (bash, gcc, python 등) │
├──────────────────────────────────────┤
│ LxCore.sys / Lxss.sys │
│ (Linux 시스템 콜 → NT 시스템 콜 변환)│
├──────────────────────────────────────┤
│ Windows NT 커널 │
└──────────────────────────────────────┘
→ 시스템 콜 번역 방식 (호환성 한계)
WSL 2:
┌──────────────────────────────────────┐
│ Linux 사용자 공간 │
│ (bash, gcc, python, docker 등) │
├──────────────────────────────────────┤
│ 실제 Linux 커널 (경량 VM 내부) │
├──────────────────────────────────────┤
│ 경량 유틸리티 VM (Hyper-V 기반) │
├──────────────────────────────────────┤
│ Windows NT 커널 + Hyper-V │
└──────────────────────────────────────┘
→ 완전한 Linux 커널 실행 (높은 호환성)
| 특성 | WSL 1 | WSL 2 |
|---|---|---|
| 아키텍처 | 시스템 콜 변환 | 경량 VM (실제 Linux 커널) |
| 시스템 콜 호환성 | 부분적 | 완전 |
| 파일 시스템 성능 | Windows FS 빠름 | Linux FS 빠름 |
| 네트워크 | 호스트와 동일 | NAT 기반 |
| Docker 지원 | 미지원 | 지원 |
| 메모리 | 공유 | 별도 할당 (동적) |
# WSL 기본 명령어
# 설치 가능한 배포판 목록
wsl --list --online
# Ubuntu 설치
wsl --install -d Ubuntu
# WSL 버전 확인
wsl -l -v
# 기본 배포판을 WSL 2로 설정
wsl --set-default-version 2
# Linux 배포판 시작
wsl -d Ubuntu
# Windows에서 Linux 파일 접근
# \\wsl$\Ubuntu\home\user\
5. 정리
Linux
- 커널: 모놀리식 + 동적 모듈 로딩
- 프로세스: fork/exec 모델, task_struct 기반, CFS 스케줄러
- 메모리: 가상 메모리, 페이지 캐시, slab 할당자
- 파일 시스템: VFS로 다양한 파일 시스템 통합, ext4가 기본
- 강점: 오픈소스, 서버/클라우드 환경, 커스터마이징 용이
Windows 10
- 커널: 하이브리드 구조, Executive 서비스 계층
- 프로세스: CreateProcess 모델, 객체 기반 관리, 우선순위 부스트
- 메모리: Paged/NonPaged 풀, Section 객체, 작업 집합 관리
- 파일 시스템: NTFS (MFT 기반, ACL, ADS, EFS 지원)
- 강점: 데스크톱 호환성, 엔터프라이즈 관리, WSL로 Linux 통합
퀴즈: Linux와 Windows 비교
Q1. Linux의 모놀리식 커널과 Windows의 하이브리드 커널의 차이점은?
A1. Linux의 모놀리식 커널은 프로세스 관리, 메모리 관리, 파일 시스템, 드라이버 등 모든 핵심 기능이 하나의 커널 공간에서 실행되어 성능이 좋지만, 오류 시 전체 시스템에 영향을 줍니다. Windows의 하이브리드 커널은 핵심 기능은 커널 모드에 두되, 일부 서비스(환경 서브시스템 등)를 사용자 모드에 배치하여 안정성과 성능의 균형을 맞춥니다.
Q2. Linux의 fork()와 Windows의 CreateProcess()의 차이점은?
A2. fork()는 현재 프로세스를 복제하여 자식 프로세스를 만듭니다. 부모와 자식은 같은 코드를 실행하다가 exec()으로 다른 프로그램을 로드합니다. Copy-on-Write로 효율적입니다. CreateProcess()는 처음부터 새로운 프로세스를 만들고 지정된 실행 파일을 바로 로드합니다. fork+exec 2단계를 하나로 합친 것과 유사합니다.
Q3. WSL 1과 WSL 2의 핵심 차이점은?
A3. WSL 1은 Linux 시스템 콜을 NT 커널 시스템 콜로 변환하는 에뮬레이션 방식으로, 일부 시스템 콜이 지원되지 않는 호환성 한계가 있습니다. WSL 2는 Hyper-V 기반 경량 VM에서 실제 Linux 커널을 실행하므로 완전한 시스템 콜 호환성을 제공하며 Docker도 지원합니다.
[OS Concepts] 20. Linux and Windows 10 Operating System Comparison
Linux and Windows 10 Operating System Comparison
Linux and Windows are operating systems with different design philosophies. This article compares the kernel architecture, process management, memory management, and file systems of both operating systems, and also examines Windows Subsystem for Linux (WSL).
1. Linux System Overview
Linux Kernel Architecture
Linux is based on a monolithic kernel but achieves flexibility through a module system.
┌───────────────────────────────────────────────┐
│ User Space │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │ bash │ │ nginx│ │ gcc │ │ java │ │
│ └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ │
│ └────────┴────────┴────────┘ │
│ │ System Call Interface │
├──────────────┴────────────────────────────────┤
│ Kernel Space │
│ ┌─────────────────────────────────────────┐ │
│ │ Process Management │ │
│ │ Scheduler │ Process creation │ Signals │ │
│ ├─────────────────────────────────────────┤ │
│ │ Memory Management │ │
│ │ Virtual memory │ Page cache │ slab │ │
│ ├─────────────────────────────────────────┤ │
│ │ VFS (Virtual File System) │ │
│ │ ext4 │ XFS │ Btrfs │ NFS │ tmpfs │ │
│ ├─────────────────────────────────────────┤ │
│ │ Network Stack │ │
│ │ TCP/IP │ Sockets │ Netfilter │ eBPF │ │
│ ├─────────────────────────────────────────┤ │
│ │ Device Drivers │ │
│ │ Block │ Char │ Network │ USB │ │
│ └─────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────┐ │
│ │ Hardware Abstraction │ │
│ └─────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ Hardware │
└───────────────────────────────────────────────┘
Linux Process Management
// Linux의 프로세스 구조 (task_struct 주요 필드)
struct task_struct {
volatile long state; // 프로세스 상태
int prio; // 우선순위
struct mm_struct *mm; // 메모리 정보
struct fs_struct *fs; // 파일 시스템 정보
struct files_struct *files; // 열린 파일 테이블
struct signal_struct *signal; // 시그널 정보
pid_t pid; // 프로세스 ID
pid_t tgid; // 스레드 그룹 ID
struct task_struct *parent; // 부모 프로세스
struct list_head children; // 자식 프로세스 목록
// ...
};
Linux Process States:
┌─────────┐ fork() ┌─────────┐
│ Does not│────────→ │ READY │
│ exist │ │ (runnable│
└─────────┘ │ ) │
└────┬────┘
Scheduling │ Preemption
┌────┴────┐
│ RUNNING │
└────┬────┘
I/O wait │ │exit()
┌────┴──┐ │
│SLEEPING│ │
│(waiting)│ │
└────────┘ │
┌─────┴───┐
│ ZOMBIE │
│(exited) │ → wait() → removed
└─────────┘
Linux Process Scheduler (CFS)
CFS (Completely Fair Scheduler) distributes CPU time fairly based on virtual runtime.
CFS Red-Black Tree:
(sorted by vruntime)
B (vruntime=50)
╱ ╲
A (30) ╱ ╲ D (80)
╱ ╲
C (45) E (100)
→ Leftmost node (A, vruntime=30) is next to run
→ After running, A's vruntime increases → tree rebalanced
→ O(log n) insert/delete
Linux Memory Management
Linux Process Virtual Address Space (64-bit):
High address
┌──────────────────────┐ 0xFFFFFFFF...
│ Kernel space │
│ (shared by all) │
├──────────────────────┤ 0x7FFF...
│ Stack (↓ grows) │
│ (gap) │
│ mmap region │ ← shared libs, mmap
│ (gap) │
│ Heap (↑ grows) │ ← malloc/brk
├──────────────────────┤
│ BSS (uninit.) │
├──────────────────────┤
│ Data (init.) │
├──────────────────────┤
│ Text (code) │
└──────────────────────┘ 0x0000...
Low address
Linux File System Management
# Linux에서 지원하는 주요 파일 시스템
# ext4 : 범용 (가장 널리 사용)
# XFS : 대용량 파일/고성능
# Btrfs : CoW, 스냅샷, 압축
# tmpfs : 메모리 기반 임시 파일 시스템
# procfs : 프로세스 정보 (/proc)
# sysfs : 장치/드라이버 정보 (/sys)
# 마운트된 파일 시스템 확인
df -hT
# Filesystem Type Size Used Avail Use% Mounted on
# /dev/sda1 ext4 100G 45G 50G 48% /
# tmpfs tmpfs 16G 0 16G 0% /dev/shm
Linux Kernel Modules
Kernel functionality can be dynamically added/removed at runtime.
// 간단한 커널 모듈 예시
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Example");
MODULE_DESCRIPTION("Hello World Module");
static int __init hello_init(void) {
printk(KERN_INFO "Hello, Kernel Module!\n");
return 0;
}
static void __exit hello_exit(void) {
printk(KERN_INFO "Goodbye, Kernel Module!\n");
}
module_init(hello_init);
module_exit(hello_exit);
# 커널 모듈 관리 명령어
lsmod # 로드된 모듈 목록
sudo insmod hello.ko # 모듈 로드
sudo rmmod hello # 모듈 언로드
sudo modprobe module_name # 의존성 자동 해결 로드
modinfo module_name # 모듈 정보 확인
2. Windows 10 System Overview
Windows Architecture
Windows uses a hybrid kernel architecture.
┌───────────────────────────────────────────────┐
│ User Mode │
│ ┌────────────────────────────────────────┐ │
│ │ System Processes │ │
│ │ Service Mgr │ LSA │ Session Manager │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ Subsystems │ │
│ │ Windows (Win32) │ POSIX │ WSL │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ Environment Subsystem DLLs │ │
│ │ ntdll.dll │ kernel32.dll │ user32.dll│ │
│ └────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ Kernel Mode │
│ ┌────────────────────────────────────────┐ │
│ │ Executive │ │
│ │ Object Mgr │ Process Mgr │ Memory Mgr│ │
│ │ I/O Mgr │ Cache Mgr │ Security │ │
│ │ Config Mgr │ PnP Mgr │ Power Mgr │ │
│ ├────────────────────────────────────────┤ │
│ │ Kernel │ │
│ │ Scheduling │ Sync │ Interrupt handler│ │
│ ├────────────────────────────────────────┤ │
│ │ HAL (Hardware Abstraction) │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ Device Drivers │ │
│ └────────────────────────────────────────┘ │
├───────────────────────────────────────────────┤
│ Hardware │
└───────────────────────────────────────────────┘
Windows Object Manager
The Windows kernel manages nearly all resources as objects.
Object Manager Namespace:
\
├── Device
│ ├── HarddiskVolume1
│ ├── Tcp
│ └── Null
├── ObjectTypes
│ ├── Process
│ ├── Thread
│ ├── File
│ ├── Mutex
│ └── Semaphore
├── Sessions
│ └── 1
│ └── BaseNamedObjects
│ └── MyMutex
└── GLOBAL??
├── C: → Device\HarddiskVolume1
└── D: → Device\CdRom0
Windows Scheduling
Windows Priority Levels:
31 ┌──────────────────┐
│ Real-time class │ 16-31: Real-time priority
16 ├──────────────────┤
15 │ Variable class │ 1-15: Dynamic priority
│ │ (temporary boost on I/O)
1 ├──────────────────┤
0 │ Idle │ 0: System idle thread
└──────────────────┘
Priority Boost:
- Interactive processes: Foreground boost
- I/O completion: Temporary priority raise
- Starvation prevention: Boost long-waiting threads
NTFS (NT File System)
NTFS Key Features:
┌──────────────────────────────────────────┐
│ MFT (Master File Table): │
│ - Stores all file/directory metadata │
│ - Each entry ~1KB │
│ - Small files stored directly in MFT │
│ │
│ Additional Features: │
│ - Journaling (transaction log) │
│ - File-level compression │
│ - File-level encryption (EFS) │
│ - Alternate Data Streams (ADS) │
│ - ACL-based fine-grained access │
│ - Disk quotas │
│ - Symbolic links, junctions │
└──────────────────────────────────────────┘
3. Linux vs Windows Comparison
Kernel Architecture
| Property | Linux | Windows |
|---|---|---|
| Kernel type | Monolithic (+ modules) | Hybrid |
| Source code | Open source (GPL) | Proprietary (some open) |
| Device drivers | In-kernel/modules | Kernel/user-mode drivers |
| File system | VFS abstraction | I/O manager + filter drv |
| Security model | DAC + MAC (SELinux) | ACL + integrity levels |
Process Model Comparison
Linux: Windows:
┌─────────────────────┐ ┌─────────────────────┐
│ Process (fork) │ │ Process │
│ ┌────┐ │ │ (CreateProcess) │
│ │Task│ = process │ │ ┌──────┐ ┌──────┐ │
│ └────┘ │ │ │Thread│ │Thread│ │
│ │ │ └──────┘ └──────┘ │
│ Thread = lightweight│ │ │
│ process (clone) │ │ Fiber: │
│ ┌────┐ ┌────┐ │ │ User-mode threads │
│ │Task│ │Task│ │ │ (cooperative sched.) │
│ └────┘ └────┘ │ └─────────────────────┘
│ → shared mm_struct │
│ (address space) │
└─────────────────────┘
Linux fork(): Process duplication (CoW)
Windows CreateProcess(): Create new process directly
File System Comparison
| Property | Linux (ext4) | Windows (NTFS) |
|---|---|---|
| Metadata | inode | MFT record |
| Max file size | 16 TiB | 256 TiB |
| Journaling | Supported | Supported |
| Permissions | POSIX (rwx) | ACL |
| Case sensitivity | Sensitive | Preserving (insens.) |
| File streams | Single | Multiple (ADS) |
| Encryption | dm-crypt (vol.) | EFS (per-file) |
IPC Comparison
Linux IPC: Windows IPC:
- pipe / named pipe (FIFO) - Named Pipes
- UNIX domain sockets - Mailslots
- System V IPC - Shared Memory (Section)
(shmem, semaphore, msgqueue) - COM / DCOM
- POSIX IPC - Windows Messages
- D-Bus - RPC
- netlink sockets - ALPC (Advanced Local
- io_uring Procedure Call)
4. Windows Subsystem for Linux (WSL)
WSL enables native execution of Linux binaries on Windows.
WSL 1 vs WSL 2
WSL 1:
┌──────────────────────────────────────┐
│ Linux User Space │
│ (bash, gcc, python, etc.) │
├──────────────────────────────────────┤
│ LxCore.sys / Lxss.sys │
│ (Linux syscall → NT syscall xlation) │
├──────────────────────────────────────┤
│ Windows NT Kernel │
└──────────────────────────────────────┘
→ Syscall translation (compatibility limits)
WSL 2:
┌──────────────────────────────────────┐
│ Linux User Space │
│ (bash, gcc, python, docker, etc.) │
├──────────────────────────────────────┤
│ Real Linux Kernel (inside light VM) │
├──────────────────────────────────────┤
│ Lightweight Utility VM (Hyper-V) │
├──────────────────────────────────────┤
│ Windows NT Kernel + Hyper-V │
└──────────────────────────────────────┘
→ Full Linux kernel (high compatibility)
| Property | WSL 1 | WSL 2 |
|---|---|---|
| Architecture | Syscall xlation | Lightweight VM (real kernel) |
| Syscall compat. | Partial | Full |
| File system perf | Windows FS fast | Linux FS fast |
| Network | Same as host | NAT-based |
| Docker support | Not supported | Supported |
| Memory | Shared | Separate (dynamic) |
# WSL 기본 명령어
wsl --list --online # 설치 가능한 배포판 목록
wsl --install -d Ubuntu # Ubuntu 설치
wsl -l -v # WSL 버전 확인
wsl --set-default-version 2 # 기본 WSL 2로 설정
wsl -d Ubuntu # Linux 배포판 시작
# Windows에서 Linux 파일 접근: \\wsl$\Ubuntu\home\user\
5. Summary
Linux
- Kernel: Monolithic + dynamic module loading
- Process: fork/exec model, task_struct-based, CFS scheduler
- Memory: Virtual memory, page cache, slab allocator
- File System: VFS unifies various file systems, ext4 as default
- Strengths: Open source, server/cloud environments, highly customizable
Windows 10
- Kernel: Hybrid architecture, Executive services layer
- Process: CreateProcess model, object-based management, priority boost
- Memory: Paged/NonPaged pools, Section objects, working set management
- File System: NTFS (MFT-based, ACL, ADS, EFS support)
- Strengths: Desktop compatibility, enterprise management, Linux integration via WSL
Quiz: Linux and Windows Comparison
Q1. What is the difference between Linux's monolithic kernel and Windows's hybrid kernel?
A1. Linux's monolithic kernel runs all core functions -- process management, memory management, file systems, and drivers -- in a single kernel space, providing good performance but affecting the entire system on errors. Windows's hybrid kernel keeps core functions in kernel mode while placing some services (environment subsystems, etc.) in user mode, balancing stability and performance.
Q2. What is the difference between Linux's fork() and Windows's CreateProcess()?
A2. fork() duplicates the current process to create a child process. Parent and child run the same code until exec() loads a different program. It is efficient with Copy-on-Write. CreateProcess() creates a new process from scratch and loads the specified executable immediately. It is similar to combining the fork+exec two-step into one.
Q3. What is the key difference between WSL 1 and WSL 2?
A3. WSL 1 uses an emulation approach that translates Linux system calls to NT kernel system calls, with compatibility limitations for some system calls. WSL 2 runs an actual Linux kernel inside a Hyper-V-based lightweight VM, providing full system call compatibility and Docker support.