IT/컴퓨터구조와 운영체제

[운영체제란] 운영체제의 역할, HW의 support

kykyky 2024. 4. 21. 17:11

운영체제의 역할


✅Abstact machine

hide underlying details
API 제공, system calls


✅Resource manager

각 application에 시간적/공간적 공유 자원을 allocate
   시간적: CPU(app간), network
   공간적: memory(app간), disk(user간)

한정적 자원의 사용을 효율적으로.

   overhead 최소화


✅protection

application 간에 서로서로 보호
OS 보호
hardware에의 직접적 접근 방지

 

 

운영체제를 위한 HW support

 

✅app이 실행되는 원리

OS 실행 시작됨

이 OS의 코드는 메모리의 어딘가에 들어감

OS의 instruction이 처리됨

OS는 사용자 입력을 받아 특정 app을 인식함

OS는 실행하려는 app의 프로그램 파일 (디스크에 있음)을 메모리에 load

이것의 시작 instruction의 주소를 Program Counter에 load

그러면 CPU는 이 app의 instruction을 처리함

 

✅interrupt

control이 app으로부터 OS로 넘어감

timer interrupt가 끝나면

PC는 HW에 의해 interrupt handler의 첫 instruction 주소를 가리키게 되고,

HW는 OS를 interrupt handler (상정된 위치. OS의 일부임)에서 실행하기 시작.

 

✅Trap

trap을 통해 system call이 시작되면

PC trap handler (정확히는? system call handler. that the OS set up previously)을 가리키게 되고,

mode bit이 설정됨으로써 kernel mode로 승격된다.

이제 system call handler에서 처리가 시작된다.

 

 

✅switching 

app과 processor의 state를 캡처

app의 모든 memory값을 보존

CPU의 모든 register값을 memory의 어딘가에 복사해놓음

재시작 시: 이 register 값을 reload

 

✅access mode

CPU의 PSW: kernel mode 혹은 user mode를 가리킴 -> access mode를 알려줌

? CPL이라는 것도 0(kernel mode) ~ 3(user mode)을 통해 mode 설정함..?

 

User mode

- User applications run in user mode 
- cannot...

typically initiate an I/O request to the disk

access any physical memory page

send a packet on the network

disable interrupts 

 

Kernel mode (privileged mode)

- OS

- able to...

fully access to the hardware of the system

initiate an I/O request

make more memoryavailable to a program

 

✅memory protection

main memory kernel과 user app 각각을 위한 영역이 나뉘어져 있음