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
  1. open("/a/b/c/d/e.hwp") ↓
  2. directory search ↓
  3. file metadata를 disk에서 memory로 load ↓
  4. open-file table에 저장 ↓
  5. fd 반환 ↓
  6. 이후 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

  1. file별로 index block을 가짐
  2. 이 index block에는 disk block에 대한 pointer 배열이 저장되어 있음.
mapping
  1. directed
  2. single indirect
  3. double indirect
UNIX: use combined scheme

0x32. free-space management

비어 있는 disk block들을 추적하는 방법

method저장 방식장점단점
bitmapblock마다 1 bit연속 free block 찾기 쉬움bitmap 저장 공간 필요
linked listfree block끼리 연결extra space 적음연속 공간 찾기 어려움
groupingfree block 번호를 묶어서 저장linked list보다 탐색 적음구조가 조금 더 복잡
counting(start, count) 저장연속 free 구간에 강함흩어진 free block에는 약함