2 분 소요

I/O Devices

  • Interface
    • 시스템 소프트웨어(device driver) 가 operation 을 control 하도록 해줍니다.
    • 모든 devices 들은 구체적인 interface 와 interaction 을 위한 protocol 을 가지고 있습니다.
  • Internal Structure
    • Micro-Controller (CPU)
    • Memory
    • Other hardware-specific chips

Protocol Example

Protocol 의 example 입니다. 하지만 polling 문제와 PIO 문제가 있는 비효율적인 예 입니다.
Polling : status 가 busy 상태일 때 CPU 자원 낭비
PIO : CPU is involved with the data movement

While (STATUS == BUSY)
    ; // wait until device is not busy
    Write data to DATA register
    Write command to COMMAND register
        (Doing so starts the device and executes the command)
While (STATUS == BUSY)
    ; // wait until device is done with your request

Interrupts (solution of polling)

Interrupt 를 이용해 CPU Overhead 를 감소시킵니다

  • device polling 대신에 OS가 request 하여 polling 중인 process 를 sleep 하게 하고 context switch 합니다
  • device 가 operation 을 완료하면 hardware interrupt 를 발생시켜 CPU를 OS에게 다시 부여합니다.

Direct Memory Access (solution of PIO)

data 이동을 좀 더 효율적으로 DMA 를 이용합니다

  • DMA engine 이라는 별도의 하드웨어를 이용해 CPU를 대신에 데이터를 이동시켜 줍니다.
  • 운영체제는 DMA engine 에게 메모리 주소와 그 크기에 대해 명령합니다.
  • DMA 가 끝나면 DMA controller 가 interrupt 를 발생시킵니다.

Methods of Device Interaction

Device driver 가 I/O device 들의 register 에게 접근할 수 있는 instructions 들이 정의되어 있습니다.

  • I/O instructions (usually privileged)
  • Memory-mapped I/O

HDD

I/O Time

T(I/O) = T(seek) + T(rotation) + T(transfer)

Disk Scheduling

운영체제는 디스크에 접근하는 I/O 순서를 알고리즘에 의해 결정하여 전체적인 I/O Time 을 줄입니다.

SSTF (shortest seek time first)

현재 위치에서 가장 짧은 seek time 을 가지는 request 를 우선적으로 수행합니다.

문제점

OS는 실제로 disk 의 track 정보를 알 수 없으므로 sector 번호 개념에서 가장 가까운 block 을 접근해야 합니다.

Elavator(aka SCAN or C-SCAN)

  • SCAN : Head 가 back and forth sector 로 이동하며 request 합니다.
    • starts at 54 : 37 -> 14 -> 65 -> 98 -> 122 …
  • C-SCAN : 낮은 sector 에서 큰 sector 로 이동합니다
    • starts at 54 : 65 -> 67 -> 98 -> 122 -> 124 -> 183 -> 14 -> 37

문제점

disk 의 rotation costs 는 고려하지 않은 방법입니다.

SPTF (shortest positioning time first)

앞선 2개의 알고리즘은 OS가 구현하지만, SPTF 는 DISK 가 구현합니다. 그러므로 Sector 와 Track 의 구조를 알 수 있고 seek time 과 rotation time 까지 고려하여 알고리즘을 구현할 수 있습니다.

  • 만약 seek time 이 rotation delay 보다 크다면 SSTF 를 사용합니다.
  • Rotation time 이 더 크다면 더 멀리있는 request 를 수행합니다.

업데이트: