Search

Old Version of Address Translation

Address Translation

프로그램을 짜고 실행하는 코드 내에서는 모두 가상 주소에 접근하도록 되어있으나, 결국에는 데이터를 메모리로부터 가져오기 위해서는 물리 주소가 필요하며 그러한 변환을 운영체제가 관리해준다.
Fetch, Load, Store
Fetch : 머신 instruction을 CPU가 가져와 실행하기 위해 Fetch
Load : 실행하는 인스트럭션에 의해 메모리에 있는 데이터를 레지스터로 가져오는 것
Store : 레지스터를 메모리로 다시 저장

Hardware-based Address Translation

Address 번역은 하드웨어가 제공하는 메커닉에 의해 변환된다.
CPU마다 Address Translation하는 방법(도구)이 조금씩 차이가 있다.
다만 하드웨어 혼자서는 번역이 안되며 OS가 AT를 위해 하드웨어설정과 자료구조 구축을 잘 해야함.
유연하게 VM을 만드는 방법
어플리케이션의 필요에 기반해 어떻게 유연성을 제공할 것인가?
메모리 어드레스 스페이스는 어떻게 해당 프로세스만 안전하게 접근하도록 지킬 것인가?
메모리를 위한 자료구조를 어떻게 만들 것인가?

Assumptions for Simple Memory Virtualization

1.
한 프로세스를 위한 어드레스 스페이스는 물리적으로 연속된 공간에 존재한다.
2.
한 프로세스를 위한 어드레스 스페이스는 너무 크지 않아야 한다.(피지컬 메모리보다 작음)
3.
모든 프로세스의 어드레스 스페이스는 똑같은 크기를 가진다.

Memory Relocation

Dynamic Relocation

어드레스 스페이스의 슬롯이 응용프로그램이 실행될때마다 위치가 바뀔 수 있음.
Base and Bounding
Base 레지스터 : 피지컬 메모리의 시작지점을 알려줌
bounds 레지스터 : 끝 지점
어드레스 변환을 해보자.
Physical address = Base + Virtual address(한 어드레스 스페이스 내의 오프셋처럼 취급가능)
128: movl 0x0(%ebx), %eax PC: 128 -> 32KB(32768B) + 128B = 32896B x: 15KB -> 32KB + 15KB = 47KB
C
복사
바운드로 프로텍션해보자.
접근하려는 메모리 레퍼런스가 바운드보다 클 경우 CPU는 exception을 도출할 것이다.

Hardware Support

Hardware Requirements
Notes
Privileged mode
Needed to prevent user-mode processes from executing privileged operations
base/bounds registers
Need pair of registers per CPU to support address translation and bounds checks
Ability to translate virtual addresses and check if within bounds
Circuitry to do translations and check limits (in this case, quite simple)
Privileged instruction(s) to update base/bounds
OS must be able to set these values before letting a user program run
Privileged instruction(s) to register exception handlers
OS must be able to tell hardware what code to run if exception occurs
Ability to raise exceptions
When processes try to access privileged instructions or out-of-bounds memory