본 자료는 인하대학교 정진만 교수님의 Operating System 강의 자료를 참고하여 제작되었습니다.
Processor Register
- Program Counter (PC)
- Instruction Register (IR)
- Program Status Word (PSW)
- 상태 정보를 가지고 있음.
- Conditional code, interrupt masks, etc.
- Memory Address Register (MAR)
- 메모리 주소를 저장.
- Memory Buffer Register (MBR)
- 데이터 값을 저장.
Instruction
< Instruction format >
+--------+----------+
| opcode | operands |
+--------+----------+
- Instruction Fetch
- PC는 다음 명령어 주소를 저장한다.
- IR에 적재한다.
- Instruction Cycle
- PC -> MAR
- MAR -> MBR
- MBR -> IR
- PC = PC + 1
OS Time Management
-
Time-driven Management
relative time
OS가 제어할 때 사용한다. -
Managing the current time of day
absolute time
파일 시스템 시간 볼 때 사용한다.
System Timer
-
PIT(Programmable Interval Timer, System Timer)
relative time
Hz를 우리가 설정 가능하다.
Hz(tick)- tick ratio
- 보통 100Hz로 설정
Jiffies(tick)
- tick의 수 (global variables)
- 컴퓨터 부팅 후 작동
-
RTC(Real Time Clock)
absolute time
HW clock command (/dev/rtc)
Interrupt
- Interrupt: Hardware event
- Interrupt Handler: OS code
- Time Interrupt: time slice를 넘으면 발생
그래서 Interrupt가 발생하면, Interrupt handler가 관리한다.
Interrupt Machanism
- 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 Processing

<Hardware>
- Interrupt 발생
- 현 명령어 종료
- Interrupt 신호 인지
- Control Stack에 PSW와 PC를 push
- Interrupt에 맞는 PC를 load
<Software>
- 프로세스 상태 정보를 저장 (
Save all) - 프로세스 interrupt (
Interrupt Service Routine(ISR)) - 프로세스 상태 복구
- PSW와 PC를 복구 (
Restore all)
Interrupt and Exception
Interrupt는 hardware에서 발생하는 것이라 비동기 처리가 되고.
Exception은 divid by zero처럼 CPU에서 발생하는 것이라 동기 처리이다.
-
Interrupt
- Asynchronous Interrupt
- H/W 장치에서 생성
-
Exception
- Synchronous Interrupt
- CPU에서 생성