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.
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"
Exceptions
Change in control flow in response to a system event
Implemented using combination of hardware and OS software
Process context switch
Mainly implemented by OS
Signals
Mainly implemented by OS
Caused by events external to the processor
Ex
Timer interrupts
I/O interrupt from external devicce
Caused by events that occur as a result of executing an instruction:
Intentional
Examples: system calls, breakpoint traps, special instructions
Returns control to "next" instruction
Unintentional but possibly recoverable
Examples: page fault, general protection fault, floating point exception
Either re-executes faulting ("current") instruction or aborts
Unintentional and unrecoverable
Examples: parity error, machine check
Aborts current program
*page fault, general protection fault는 메모리 주소값에 접근하려고 하다가 발생하는 오류. 모두 segmentation fault라는 에러 메시지가 뜬다. segment와는 관계 없는 에러인데 예전부터 이 말을 써왔어서 이렇게 에러가 뜬다.
이 글이 정말 도움이 되었습니다.