Runtime Environment
Program execution model을 구현한 것이다.
프로그램 실행을 위해서 register와 memory를 어떻게 사용하는가를 말한다.
이는 processor designer가 독자적으로 결정할 수 있는 것이 아니다.
CPU, OS, compiler, 주요 application designer(programmer)들의 협의에 결정된다.
즉, 많은 HW-SW interaction을 다룬다.
Register
Register의 이름은 대부분 프로그램 실행, procedure call/return과 관련되어 붙어진 것이다.
Memory
각 프로세스는 아래와 같은 2GB의 process virtual address space을 가진다.
- Stack
- Automatic storage
- Procedure이 call/return 될 때 frame이 push/pop 된다.
- Dynamic data
- Heap
- C에서의 malloc이나 Java에서의 new와 같이 사용자가 dynamic allocate하는 data들이 저장된다.
- Object lifetime
- Static object : 프로그램 시작 ~ 끝
- Local object : procedure call ~ return
- Heap object : memory allocation ~ deallocation(free)
Static
Static : compile time ↔ Dynamic : runtime
Executable file 안에 들어있다.
Executable file은 static code와 static data가 들어있다.
Static Data
External variable로, function 바깥에 선언된 variables이다.
Static data가 저장된 위치는 0x1000 0000 ~ 0x1000 FFFF(64KB) 까지로 항상 고정되어 있다.
<pre>$gp</pre>는 항상 0x1000 8000으로 고정된 값을 가진다.
이는 static data의 중간 위치로, compiler는 static data에 <pre>$gp</pre>에 대한 offset으로 접근한다.
따라서 base addressing을 사용한다.
<pre>lw $t0, 32($gp)</pre>와 같이 접근할 수 있다.
<pre>$gp</pre>는 static data의 중간위치이기 때문에 offset은 sign number이다.
이를 이용해서 모든 static data에 접근 가능하다.
이것은 load instruction에서 offset operand의 길이가 16bit인 이유 중 하나이다.
Static data의 위치가 고정되어 있는 이유?
External variable들은 function들 끼리 공유하는 것으로, 모든 fucntion들에서 external variable의 위치를 알아야 한다.
이를 위해 static data의 위치는 고정되어있다.
Text
(Static) program code로, $2^{28}$(256MB)의 크기이다.
Jump instruction을 이용해서 text 안에서 jump을 할 수 있다.
* Jump instruction : jump with 26bit-word-offset
User process의 process virtual address space가 2GB인 이유? (4GB가 아닌 이유)
각 user process는 2GB의 virtual address space을 사용하고, 남은 2GB는 OS에서 사용한다.
만약 OS와 user process가 합쳐서 4GB씩 가지고 있다면, system call/return 시 환경을 바꿔줘야 한다.
그러나 OS와 user process가 2GB씩 나눠가지고 있으면 단순히 jump을 통해 전환이 가능하다.
또한 주소의 MSB(최상단 bit)을 통해서 mode을 구분할 수 있다.
MSB가 1이라면 kernel space인 것이고, MSB가 0이라면 user space이다.
Address Space의 저장
Address space는 disk에 저장되어 있다.
그러나 disk의 접근속도는 매우 느리기 때문에 main memory에 올려놓는다.(caching)
더 나은 속도를 위해서 main memory을 cache memory(on chip cache)에 올려놓고 사용한다.(caching)
Disk는 프로그램 실행을 위한 부분과 permanent storage(file systems)으로 구성되어 있다.
- 프로그램 실행을 위한 부분
- 동적인 특성을 가진다.
- Program 실행에 따라 달라진다.
- Permanent storage(file systems)
- 파일을 변화하지 않는 이상 그대로 유지된다.
- 전원이 꺼져도 유지된다.
'Computer Science > Computer Architecture' 카테고리의 다른 글
3. Computer Arithmetic (0) | 2021.05.16 |
---|---|
2. Compile, Link, Run (0) | 2021.05.09 |
2. MIPS : Non-Leaf Procedure (1) | 2021.05.09 |
2. MIPS : Program Execution (0) | 2021.04.22 |
2. MIPS : Control Instruction (2) | 2021.04.20 |
댓글