[시스템 프로그래밍] Exception

여경민·2023년 7월 19일

Exceptional Control Flow

Interrupt

Trap

Fault

Abort

Control Flow

Processors do only one thing: CPU simply reads and executes(interprets) a sequence of instructions, one at a time.
This sequence is CPU's control flow.

Altering the Control Flow

Two mechanisms to change control flow
-Jumps and branches
-Call and return

Insufficient for a useful system: Must react to changes in system state (ex: user hits Ctrl-C at the keyboard)

System needs mechanisms for "exceptional control flow"

Low Level mechanisms

Exceptions
Change in control flow in response to a system event
Implemented using combination of hardware and OS software

Higher Level mechanisms

Process context switch
Mainly implemented by OS
Signals
Mainly implemented by OS

Asynchronous Exceptions (Interrupts)

Caused by events external to the processor
Ex
Timer interrupts
I/O interrupt from external devicce

Synchronous Exceptions

Caused by events that occur as a result of executing an instruction:

Traps

Intentional
Examples: system calls, breakpoint traps, special instructions
Returns control to "next" instruction

Faults

Unintentional but possibly recoverable
Examples: page fault, general protection fault, floating point exception
Either re-executes faulting ("current") instruction or aborts

Aborts

Unintentional and unrecoverable
Examples: parity error, machine check
Aborts current program

*page fault, general protection fault는 메모리 주소값에 접근하려고 하다가 발생하는 오류. 모두 segmentation fault라는 에러 메시지가 뜬다. segment와는 관계 없는 에러인데 예전부터 이 말을 써왔어서 이렇게 에러가 뜬다.

1개의 댓글

comment-user-thumbnail
2023년 7월 19일

이 글이 정말 도움이 되었습니다.

답글 달기