file
WHAT
DEF
1. container for data and program
2. is logical address space
3. sequential access
structure
decided by
- program
- OS
i) none
- sequence of bytes, words
ii) simple record structure
iii) complex structure
- formatted document
- e.g., hwp
- relocatable load file
- e.g., dll
HOW — file management by OS
meta structure of file
file system이 오직 관리하는 것은 meta일 뿐.
file identification
directory path + file name
multiple file system?
- file system is resident on disk
- but when multiple disks?
mounting
mount는 다른 file system의 root를 기존 directory 하나에 붙임 즉. 여러 file system을 하나의 tree로 통합한다
open system call
- file을 실제로 읽고 쓰려면 file size, location, permission, current offset 같은 metadata가 필요하다.
- 이걸 매번 disk에서 읽지 않기 위해 memory에 올려둔다.
ALG
- open("/a/b/c/d/e.hwp") ↓
- directory search ↓
- file metadata를 disk에서 memory로 load ↓
- open-file table에 저장 ↓
- fd 반환 ↓
- 이후 read(fd), write(fd)는 fd로 table lookup
0x30. HOW — file system: allocation of data in disk
0x31. allocation scheme
i) contiguous allocation
ii) linked allocation
FAT series
- FAT table을 memory에 올려두어 빠르게 random access가능
- FAT는 disk block에 대해 다음 block pointer를 저장해 둠.
iii) indexed allocation
- file별로 index block을 가짐
- 이 index block에는 disk block에 대한 pointer 배열이 저장되어 있음.
mapping
- directed
- single indirect
- double indirect
UNIX: use combined scheme
0x32. free-space management
비어 있는 disk block들을 추적하는 방법
| method | 저장 방식 | 장점 | 단점 |
|---|---|---|---|
| bitmap | block마다 1 bit | 연속 free block 찾기 쉬움 | bitmap 저장 공간 필요 |
| linked list | free block끼리 연결 | extra space 적음 | 연속 공간 찾기 어려움 |
| grouping | free block 번호를 묶어서 저장 | linked list보다 탐색 적음 | 구조가 조금 더 복잡 |
| counting | (start, count) 저장 | 연속 free 구간에 강함 | 흩어진 free block에는 약함 |