Study/OS

[OS] Computer System Overview I

__PS 2024. 4. 18. 18:08
728x90

Basic component: CPU, I/O module, bus, memory

 

Evolution of processor

-> 폰 노이만 구조의 한계를 벗어나지 못함

실행 시 메모리에 적재되어야하는데, 버스가 너무 많이 실행됨


Memory

Static RAM -> Cache

: 6 transistor, Expensive, high speed, no fresh required

 

Dynamic RAM -> Main Memory

: one transistor + one capacitor, slower than SRAM, dynamic refresh required

 

Heterogeneous Memory

1) Load and Execute -> 자주 쓰이는 모델 / hot, cool data 사용

2) Direct host access

 

Hard Disk Drive (HDD)

- Non - volatile device

진동, 충격에 약함 -> 움직이지 않는 PC에 적합

 

Flash memory

- Non - volatile memory

- slower than SRAM, faster than HDD

1) Asymmetric read and write: read가 write에 비해 1 : 8 정도로 빠름

-> HDD는 동일하다.

2) No in-place update: 제자리 쓰기가 불가능하다

3) Limited endurance: 제한된 endurance

 

Solid State Disk (SSD)

- based on flash memory

Flash Translation Layer (FTL): 플래시 메모리를 하드디스크처럼

 

Comparison

Process cycle - Cache Access - Memory Access - SSD Access - Disk Access


 

Processor Register

- General purpose register: 메모리 접근을 최소로 하고 레지스터의 사용을 최적화한다.

1) Program Counter (PC): 다음에 실행될 명령어의 주소

2) Instruction register (IR): 명령어 레지스터 / fetch된 명령어 자체

3) Program status word (PSW): condition code를 의미

4) Memory Address register (MAR): 주소가 올라옴

5) Memory Buffet register (MBR): 데이터가 올라옴

 

Instruction Set Architecture (ISA)

: 명령어 집합 구조, register + memory

-> data processing, control, processor - memory, processor - I/O

load, store -> 메모리 버스 이용

 

machine state: I/O module과는 무관, 레지스터와 메모리의 상태


 

Interrupt Mechanism

- Interrupt: 현재 수행중인 프로세스를 중단 -> system utilization + timely service를 위해

=> CPU와 I/O module의 병행을 높이기 위해

- I/O device가 CPU에게 신호를 필요할 때만 신호를 보낸다.

- system timer interrupts와 같은 인터럽트를 통해 timely service를 제공한다.

- kernel 모드로 스위치하여 인터럽트를 관리한다.

 

-  PC를 interrupt handler의 주소로 변경하고, 기존 PC값을 stack에 저장한다.

- 레지스터에 못하는 이유: 프로세스마다 PC값이 존재하므로 어느 PC값으로 들어가는지 구분할 수 없다.

 

Programmable Interrupt Controller (PIC)

1) translation: I/O device에게 IRQ#을 제공하여 interrupt signal을 interrupt vector로 변환

2) Masking -> enable, disable 조절 => 우선순위 존재

=> utilization을 높이기 위해

 

IRQ가 있어 몇 번 device인지 알 수 있음

- PIC translates device's request to IRQ #

- possible to "mask" (disable) interrupts 

 

When interrupts occur

1) PC, PSW 를 스택에 저장

2) PC를 interrupt handler의 주소로 변경 (진입점)

3) PSW를 비활성화시켜 다른 인터럽트를 막음

4) 인터럽트 종료 이후 스택에서 PC와 PSW를 추출

-> Interrupt context -> process context로 변경 => PC값 변경


 

Interrupts

Interrupt Handler saves all -> PC, PSW를 제외한 나머지 레지스터 저장, software 영역

ISR: Interrupt Service Routine, 각 인터럽트마다 어떻게 처리해야하는지 코드가 적혀있음

 

인터럽트가 PIC에 의해서 벡터 형태로 들어오면 Interrupt handler 가 IDT에서 어떤 Interrupt인지 파악하고, 이에 상응하는 ISR을 실행시킨다.

 

2가지 interrupt 존재

1) Asynchronous interrupts often called interrupts

-> H/W device에 의해 발생

-> device 등에 의한 외부 인터럽트 

 

2) Synchronous interrupts often called exception

-> CPU에 의해 발생

-> divide by zero, segmentation fault, page fault ...

-> system call을 포함한 내부에 의해 발생

 

interrupt와 exception은 같은 방식으로 처리

 

Exception

: CPU 내부, process context에서 발생, 발생 즉시 예외 수행

ex) fetch 하려는데 잘못된 주소, decode -> 잘못된 접근

-> program과 연관, process context


 

Multiple Interrupts

1) Sequential Interrupt Processing

인터럽트가 수행 중인 경우 다른 인터럽트를 disable 시킴

-> 새로운 인터럽트를 무시하고 현재 인터럽트를 진행, 끝나면 새로운 인터럽트를 수행

--> 우선순위 X, timely service X

 

2) Nested Interrupt Processing

- Define Priority for interrupts

- 현재 인터럽트 수행 중에 우선순위가 높은 인터럽트가 들어온 경우, 새로운 인터럽트를 수행