How operating systems interact with user programs and computer hardware?
Going Deeper!
- Software Interrupt and System Call
On Unix and Linux systems,software interrupt(trap) -> system calls를 요청하기 위해 사용됨
int -> x86 processors에서 software interrupt를 호출하기 위해 사용하는 assebly language instruction
ex) int $0x80 -> 16진수 형태의 interrupt number를 호출
Warning 1: syscall instruction x86 assembly language에서, system calls를 호출하는 다른 명령어인 syscall 존재 -> syscall은 int 명령어가 사용하는 parameter register와 다른 register를 사용
int $0x08 실행
interrupt vector를 참조 -> CPU는 system_call() function이 위치한 entry point로 점프
syscall table 참조 -> system_call() function은 system_call handling을 위한 특정한 함수를 호출 (ex: sys_read)
system call을 처리한 이후, user process는 작업을 계속 진행 -> system call은 synchronous하게 다뤄짐
What is the difference between Trap and Interrupt?
Trap - user process 내부에서 발생한 exception에 의해 발생 - synchronousinterrupt - invalid memory access, division by zero, breakpoint, ...
- Trap은 OS를 user mode에서 kernel mode로 변경 -> OS는 특정 actions를 진행하고 process에 대한 control을 return함 - trap handler는 synchronous하게 작동 -> os가 trap을 detect -> user process 중지 -> trap handling이 끝나면 작동
Defference Between Trap and Interrupt Trap - hardware device에서 발생 - Synchronous process - software device에 의해서만 발생 - user program instruction에 의해서만 발생 - interrupt에 포함되는 개념
Interrupt - user program에서 발생 - Asynchronous process - hardware/software device 모두에서 발생 가능 -> application이 특정 os service를 발견했거나 종료됐을 때, software interrupts 발생 - OS/user program instruction 모두에서 발생 가능
CPU와 Memory를 분리하여 명령어를 따로 저장하는 '프로그램 내장 방식'이 핵심!!! -> CPU와 Memory를 분리하고, '연산 작업'을 program memory에 순서대로 저장한 후, 해당 연산 작업이 필요해질 때 저장해놓은 program을 찾아 data 영역으로 꺼내온 뒤 입력값과 함께 전달해 CPU에 전달해 연산 작업 진행
what is program counter?
a special register that point the address of the next instruction <-> 연산 결과를 임시로 저장하는 general register