본 자료는 인하대학교 정진만 교수님의 Operating System 강의 자료를 참고하여 제작되었습니다.
Processor Register
| Register | 역할 |
|---|---|
| Program Counter (PC) | 다음에 실행할 명령어의 주소를 저장한다. |
| Instruction Register (IR) | 현재 fetch된 명령어를 저장한다. |
| Program Status Word (PSW) | 조건 코드, interrupt mask 등 CPU 상태 정보를 저장한다. |
| Memory Address Register (MAR) | 접근할 메모리 주소를 저장한다. |
| Memory Buffer Register (MBR) | 메모리에서 읽거나 메모리에 쓸 데이터 값을 저장한다. |
Instruction
< Instruction format >
+--------+----------+
| opcode | operands |
+--------+----------+
Instruction Fetch
PC가 가리키는 명령어를 가져와 IR에 적재한다.
Instruction Cycle
PC -> MARMAR -> MBRMBR -> IRPC = PC + 1
OS Time Management
| 구분 | 시간 기준 | 사용 목적 |
|---|---|---|
| Time-driven Management | relative time | OS가 일정 주기로 제어권을 얻을 때 사용한다. |
| Managing the current time of day | absolute time | 파일 시스템 시간처럼 실제 시각이 필요할 때 사용한다. |
System Timer
| Timer | 시간 기준 | 역할 |
|---|---|---|
| PIT(Programmable Interval Timer, System Timer) | relative time | OS tick을 발생시키는 타이머이다. Hz 값을 설정할 수 있고 보통 100Hz로 설정한다. |
| Jiffies | relative time | 컴퓨터 부팅 후 발생한 tick 수를 저장하는 global variable이다. |
| RTC(Real Time Clock) | absolute time | 실제 시각을 관리하는 hardware clock이다. /dev/rtc로 접근할 수 있다. |
Interrupt
| 용어 | 의미 |
|---|---|
| Interrupt | 하드웨어에서 발생하는 이벤트이다. |
| Interrupt Handler | Interrupt를 처리하는 OS 코드이다. |
| Time Interrupt | time slice를 넘으면 발생하는 interrupt이다. |
그래서 Interrupt가 발생하면, Interrupt handler가 관리한다.
Interrupt Mechanism
- Timely Service: 시간에 민감한 interrupt를 빠르게 처리하기 위해 사용한다.
- System Utilization: I/O device 이벤트를 기다리는 동안 CPU를 효율적으로 사용하기 위해 사용한다.
e.g.,
- Update the jiffies
- Update the wall time
- Update the process time
3-1. Upgrade resouce usage
3-2. Update time slice - Run dynamic timers
Programmable Interrupt Controller(PIC)
CPU랑 I/O controller 사이에서 중간 관리자 역할을 수행한다.
장치로부터 #IRQ를 받아 interrupt를 마스킹한다.
Interrupt 처리 과정

Hardware
- Interrupt가 발생한다.
- 현재 명령어를 종료한다.
- Interrupt 신호를 인지한다.
- Control Stack에 PSW와 PC를 push한다.
- Interrupt에 맞는 PC를 load한다.
Software
- 프로세스 상태 정보를 저장한다. (
Save all) - Interrupt Service Routine(ISR)을 실행한다.
- 프로세스 상태를 복구한다.
- PSW와 PC를 복구한다. (
Restore all)
Interrupt와 Exception
Interrupt는 hardware에서 발생하는 것이라 비동기 처리가 되고.
Exception은 divid by zero처럼 CPU에서 발생하는 것이라 동기 처리이다.
| 구분 | 발생 위치 | 처리 특성 | 예시 |
|---|---|---|---|
| Interrupt | H/W 장치 | 비동기 처리 | I/O 완료, timer interrupt |
| Exception | CPU | 동기 처리 | divide by zero, invalid instruction |