본문 바로가기
Study/운영체제

1. Introduction - Computer system organization and operation

by 이미뇨 2023. 4. 10.

1. Computer System Operation

콤퓨타가 실행되면 뭔일이 일어나는굥? -> 전원에 켜진다 헤헤..

 

1.Bootstrap program (firmware) 실행된다.

  • 시스템 진단 및 초기화
  • OS kernel 로드 및 실행(boot block) - (Bootstrap loader)

2.OS kernel

  • Boots (init)
  • Waits for some event (쭉 당신같은 이벤트를 기다려 왔다우..)
  • Handles event
  • 부팅 -> 리퀘스트 기다림 -> 이벤트 발생시 처리

최신 운영 체제는 interrupt driven programs을 통해서 이벤트 처리

 

2.Modern Computer System

Common bus: 컴퓨터 구성 요소 간에 데이터를 전송하는 하위 시스템, 중요한 컴포넌트를 연결

  • CPU, memory and device controllers 가 common bus로 연결되어있음 (속도가 빠르다)
  • I/O 장치와 CPU를 동시에 실행할 수 있음 (CPU랑 다른 디바이스 동시에 작업가능)
  • 메모리 경쟁 -> synchronization issue (병렬적으로 사용 ㄱㄴ)

버스 지나가유~

3. Modern Computer System (cont’d)

  • 각 device controller에는 local buffer가 있다.
    • local buffer란? : 각 장치마다 제어하기 위해 설치된 장치 컨트롤러에 장치로부터 들어오고 나가는 데이터를 임시로 저장하기 위한 작은 메모리
  • CPU는 데이터를 main memory와 local buffer 왔다갔다 이동시킴
  • I/O는 device에서 controller의 local buffer로 이동
  • Device controller는 interrupt를 발생시켜 작업이 완료되었음을 cpu에 알린다.

4.Interrupt

Interrupt: asynchronous signal (예측할수 없는 신호. 시도때도 없이 아무때나 날라온다.)

  • H/W에서 지원됨
  • interrupt 타입은 숫자(IRQ number)와 연결
  • interrupt handler에서 처리됨 (interrupt를 처리해주는 코드)

코드의 개별 segments는 각 interrupt 타입에 대해 수행해야 할 작업을 결정한다.

  • Table of interrupt handler: interrupt vector

이벤트를 처리하는 메커니즘 종류

  • H/W interrupt
    • Sending signal to CPU
  • S/W interrupt
    • System call (= monitor call): request from program => 의도 (I/O access, memory allocation, … )
    • Exception => 의도 X (Divide by zero, invalid memory access, I/O exception, …)

 

Intel Processor Event-Vector Table

Hardware process

  • PC: program counter
  • IRQ: interrupt Request
  • ISR: interrupt Service Routine

 

5. Intel Processor Event-Vector Table

Intel Processor Event-Vector Table

0~31: non-maskable, 32~255: maskable

6. Hardware Process

Hardware process

  • PC: program counter
  • IRQ: interrupt Request
  • ISR: interrupt Service Routine
InterruptRequest = FALSE;  // interrupt request line …

while(haltFlag not set during execution){
  IR = memory[PC]; // Fetch into the IR
  PC++; // Point the PC at the next instruction
  execute(IR); // Execute the current instruction
  if(InterruptRequest) { // Interrupt the current process
      save_PC(); // Save the PC
      restore_PC(IRQ); // Branch to the ISR for this IRQ
   }
}

7. Interrupt Mechanism

Interrupt handling

1. CPU가 현재 작업을 중지하고 interrupt handler로 실행을 전송

  • Interrupt vector: 인터럽트가 발생했을 때, 그 인터럽트를 처리할 수 있는 서비스 루틴들의 주소를 가지고 있는 공간

2. 인터럽트는 해당 핸들러(ISR)가 처리

3. 중단된 프로그램으로 돌아가기

  • interrupt handler를 호출하기 전에 필요한 정보(return address, state)를 저장해야 한다.

Interrupt handling

8. Interrupt-based I/O (Interrupt 기반  I/O)

1. CPU가 요청을 보내고 현재 프로세스를 계속하거나 다른 작업을 수행

2.데이터 전송이 완료되면 I/O 장치가 중단

9. Instruction-Execution Cycle (명령 - 실행 사이클)

  • memory에서 instruction(명령)을 가져와 instruction register에 저장
  • 그런 다음 instruction이 디코딩되고 memory에서 operands를 가져와 일부 internal register에 저장할 수 있다
  • operands에 대한 instruction이 실행된 후에는 결과가 memory에 다시 저장될 수 있다.

10. Main Memory

  • Register
    • CPU의 작고 빠른 메모리
  • Main memory
    • data 또는 instruction을 저장할 셀 배열
    • 각 셀은 address로 식별
    • 빠르고 휘발성이 강하다
  • 모든 형태의 메모리는 byte(바이트) 배열을 제공합니다. 각 byte(바이트)에는 own address(고유한 주소)가 있다.
    • load instruction : CPU 내의 main memory -> internal register(내부 레지스터)로 byte 또는 word를 이동
    • store instruction : 레지스터의 내용 -> 메인 메모리로 이동

11. Storage Structure

Storage Structure

12. Size and Speed of Storages

13. I/O Device Access

  • Old systems
    • 1) Busy waiting
  • Modern systems
    • 2) Interrupt-driven I/O
    • 3) DMA (Direct memory Access) (대용량 데이터의 경우)

1) Busy waiting

: CPU가 주기적으로 디바이스 상태를 확인

* Problem: CPU가 I/O device만 대기

2) Interrupt-driven I/O

: CPU가 controller에 리퀘스트 요청

* Problem: CPU가 대량의 데이터를 전송해야 한다.

3) DMA (Direct memory Access)

: Device controller가 대용량 데이터를 메인 메모리로 직접 전송

  • CPU가 데이터 전송에 관여할 필요가 없음
  • 대량 데이터를 옮겨야 하는 상황에서 선택적으로 사용

 

 

이번과에서 제일 중요한 단어 : interrupt