수정입니다
36. I/O Devices 본문
I/O Devices
- I/O : critical to computer system to interact with systems
I/O Architecture
- Buses : cpu나 ram, I/O devices 사이의 정보를 제공하는 Data path
- I/O bus : cpu와 I/O devices 사이의 data path
- 세가지의 hardware components를 연결
- I/O ports
- interfaces
- device controllers
Canonical Device
Hardware interface of Canonical Device
- status register : 현재 device의 상태를 보여줌
- command register : 명령어를 받는 reg
- data register : data를 pass & get
=> 이 세가지 reg를 이용해서 read / wrie
=> OS가 device의 행동을 control
- device 상태가 busy 인지 아닌지 확인 한 후 not busy 이면
- 쓸 data와 command를 register로 옮기고
- 위의 과정이 다 끝났는지 status를 계속 체크해줌
=> 이렇게 계속 I/O 작업이 끝났는지 아닌지 체크하고 있으면 cpu가 낭비됨
Polling
- 위의 과정을 polling이라고 함
- I/O가 끝나는 시점을 바로 캐치할 수 있다는 장점이 있음
- 하지만 polling 하는 기간 동안 cpu가 낭비됨
Interrupts
- polling 하지 않고, 그 process를 잠들게 해서 context switching을 해줌
- I/O 작업 하는 동안 다른 process가 cpu를 사용할 수 있게 되어서 낭비를 막을 수 있음
Polling vs interrupts
- 만약 device가 매우 빠르게 진행 된다면, context switching 하는 비용이 더 커서 system을 느리게 만든다
- device 가 빠르면 polling이 낫고
- device가 느리면 interrupt가 낫다는 뜻
- hybrid 하게 두가지 방법을 융합해서 쓰는 방식도 존재한다.
CPU is once again over-burdened
- cpu가 만약 large chunk of data를 가져오면, 그 copy time 동안 over-burdened 발생
DMA(Direct Memory Access)
- cpu copy time을 줄이기 위해 도입한 엔진
- data reg에 접근할 수 있는 보조 cpu의 일종
- cpu가 직접 data를 copy 하는 것이 아니라 DMA에 부탁해서, 다 되면 interrupt를 주게 함
- 3번 과정을 수행하는 동안 task 1이 잠깐 수행
- 3번 과정 => 명령어 패치
Device interaction
- 어떻게 CPU가 I/O device에 접근할 수 있을까?
1. I/O instructions(intel)
- in / out과 같은 instruction을 사용하여 device reg에 data 전송
2. memory-mapped I/O(ARM)
- bus address space 같은 memory location을 이용하여 OS가 main memory에 쓰는 대신 device에 load, store를 할 수 있게 함
'전공 > 운영체제' 카테고리의 다른 글
31. Semaphore (0) | 2024.01.16 |
---|---|
30. Condition Variables (1) | 2024.01.16 |
28. Locks (1) | 2024.01.15 |
27. Interlude : Thread API (0) | 2024.01.15 |
26. Concurrency : An Introduction (1) | 2024.01.15 |