[OS] How to Virtualize Memory?

hwi·2024년 11월 9일

OS

목록 보기
2/7

Methods

  1. Time sharing
  2. Static Relocation
  3. Base
  4. Base + Bounds
  5. Segmentation
  6. Paging

1. Time Sharing

정의

Memory에 한번에 하나의 process 올리는 방식

단점

매우매우 느림

2~6. Space Sharing

한번에 그냥 여러 프로세스의 address space를 메모리에 올려서, 느린 문제 해결
그렇다면 어떻게 각 프로세스의 address space를 관리할 것인가가 쟁점이 된다.

2. Static Relocation

정의

process로 메모리에 올라갈 때, 어디부터 할당할지를 고정 and OS가 address를 rewrite해줌

단점

protection이 전혀 안됨
한번 정해지면 address space를 옮길 수가 없음

3~4. Dynamic Relocation

정의

Base, Bound registers 이용하여 주소 변환 (by MMU(Hardware))
Kernel mode에서는 Memory access
User mode에서는 (VA -> PA)주소 변환 (base register 더해줌으로서)

장점

  • protection 문제 해결(bounds register)
  • simple
  • inexpensive
  • Fast

단점

  • 모든 process가 contiguously 하게 할당되어야 함.. -> 프로세스 사이사이 비는 메모리 공간이 wasted될 듯!

MMU

  • controlled by OS
  • base, bound register 들어있음
  • base register는 process마다 값이 다름 ()
  • VA + Base Addr = PA (계산은 H/W가 진행)

Context Switch

  • context switch가 일어날 때, Base, Bounds register는 PCB에 저장되어야 함
  • User process는 Base, Bound register를 조작할 수 없음
  • User process는 privileged mode로 전환할 수 없음.
profile
될놈

0개의 댓글