• toc {:toc}

I/O Hardware

  • I/O ν•˜λ“œμ›¨μ–΄λŠ” signal 을 λ³΄λ‚΄λ©΄μ„œ OS 와 μ†Œν†΅ν•œλ‹€.
    • Port : μž₯μΉ˜κ°„ μ—°κ²° 지점
    • Bus : PCI or PCIe bus, Expansion bus, Serial-Attached SCSI (SAS) for disks
    • Controller : 컨트둀러λ₯Ό μ΄μš©ν•΄ device 에 μ ‘κ·Όν•œλ‹€.
      • 데이터λ₯Ό λ””μŠ€ν¬μ— μ“°λŠ” μ—­ν• , Error collection μ—­ν• 
      • 메인 λ©”λͺ¨λ¦¬ μ‚¬μš©ν•˜λ„λ‘ λ§Œλ“€μ–΄μ€Œ

image

  • Direct I/O : I/O port number λ₯Ό μ‚¬μš©ν•˜μ—¬ ν• λ‹Ή (메인 λ©”λͺ¨λ¦¬ μ£Όμ†Œμ²΄κ³„μ— μ†ν•˜μ§€ μ•ŠμŒ)
  • Memory-Mapped I/O : Direct I/O 와 λ°˜λŒ€λ‘œ 메인 λ©”λͺ¨λ¦¬ μ£Όμ†Œμ²΄κ³„μ™€ I/O device λ₯Ό ν†΅ν•©ν•΄μ„œ μ‚¬μš©
    • μ£Όμ†Œλ₯Ό ν†΅ν•΄μ„œ 메인 λ©”λͺ¨λ¦¬ μ£Όμ†ŒμΈμ§€ I/O μ£Όμ†ŒμΈμ§€ ꡬ뢄 κ°€λŠ₯

Polling

  • 각 I/O byte 에 λŒ€ν•΄ λ””λ°”μ΄μŠ€μ— λ³€ν™”κ°€ μžˆλŠ”μ§€ μ§€μ†μ μœΌλ‘œ κ°μ‹œν•˜λŠ” 방식 (busy waiting λ°œμƒ)
  1. Busy bit λ₯Ό state register 둜 λΆ€ν„° μ½λŠ”λ‹€. (0 될 λ•Œ κΉŒμ§€)
  2. Host(CPU) κ°€ read write bit λ₯Ό μ„€μ •ν•˜κ³  write λ©΄ data-out register 에 데이터λ₯Ό λ³΅μ‚¬ν•œλ‹€.
  3. Host κ°€ command-ready bit λ₯Ό 1 둜 μ„€μ •ν•œλ‹€.
  4. Controller κ°€ busy bit 을 1 둜 μ„€μ •ν•˜κ³  전솑을 μ‹œμž‘ν•œλ‹€.
  5. 전솑이 λλ‚˜λ©΄ controller λŠ” bit 듀을 λ‹€μ‹œ μ΄ˆκΈ°ν™”ν•œλ‹€.

Interrupts

  • CPU κ°€ λͺ¨λ“  instruction 을 μ‹€ν–‰ν•˜κ³  λ‚œ ν›„ interrupt-request line 을 확인
    • Interupt νƒμ§€λ˜λ©΄ CPU κ°€ λ©”λͺ¨λ¦¬μ˜ κ³ μ •λœ μ£Όμ†Œμ— μœ„μΉ˜ν•œ interrupt request routine 으둜 이동
  • CPU β†’ 2 개의 interrupt request line 을 κ°–λŠ”λ‹€.
    • Nonmaskable : 회볡 λΆˆκ°€ν•œ λ©”λͺ¨λ¦¬ 였λ₯˜μ— λŒ€ν•œ 맀우 μ€‘μš”ν•œ μΈν„°λŸ½νŠΈ (μ¦‰μ‹œ μ²˜λ¦¬λ˜μ–΄μ•Ό ν•œλ‹€.)
    • Maskable : μš”μ²­λœ μ»¨νŠΈλ‘€λŸ¬μ— μ˜ν•΄ μ²˜λ¦¬λ˜λŠ” μΈν„°λŸ½νŠΈ
  • Interrupt vector β†’ μ˜¬λ°”λ₯Έ handler 둜 interrupt 전솑
    • ν•΄λ‹Ή handler 에 λŒ€ν•œ memory address 포함
    • OS λŠ” boot time 에 κ΄€λ ¨λœ interrupt handler λ₯Ό μ„€μΉ˜ν•œλ‹€.
  • μ˜ˆμ™Έμ²˜λ¦¬λ₯Ό μœ„ν•΄μ„œλ„ μ‚¬μš©λœλ‹€.
  • Multi-CPU λŠ” μΈν„°λŸ½νŠΈλ₯Ό λ™μ‹œμ— μ²˜λ¦¬ν•  수 μžˆλ‹€.
  • λΉˆλ²ˆν•˜κ³  μ‹œκ°„μ— λ―Όκ°ν•œ μ²˜λ¦¬μ— μ‚¬μš©ν•˜κ³  λΉ λ₯΄λ‹€.

Direct Memory Access

  • I/O κ°€ λ°œμƒν•˜λŠ” 경우 device μ—μ„œ CPU 둜 polling, interrupt 방식을 톡해 μ‹ ν˜Έλ₯Ό 보내고 CPU κ°€ λ‹€μŒμ˜ signal 을 처리
  • DMA λ°©μ‹μ—μ„œλŠ” CPU λ₯Ό κ±°μΉ˜μ§€ μ•Šκ³  λ°”λ‘œ Main memory 둜 μ ‘κ·Όν•œλ‹€.
  • DMA controller ν•„μš”
  • μž‘λ™ 방식
  1. CPU λŠ” DMA command block 을 λ©”λͺ¨λ¦¬μ— μž‘μ„±
  2. CPU κ°€ DMA command block μ£Όμ†Œλ₯Ό DMA controller 에 κΈ°λ‘ν•˜κ³  λ‹€λ₯Έ μž‘μ—…μ„ μ§„ν–‰
  3. DMA contoller λŠ” 직접 λ©”λͺ¨λ¦¬ λ²„μŠ€λ₯Ό μš΄μ˜ν•΄ ν•œ μ›Œλ“œμ”© 전솑

Kernel I/O Structure

  • I/O system call 은 device behavior 듀을 μΊ‘μŠν™”ν•œλ‹€.

Block and Character Devices

  • Block device : Block λ‹¨μœ„λ‘œ 데이터λ₯Ό μ£Όκ³  λ°›λŠ” 것.
  • Block device λŠ” disk drive λ₯Ό ν¬ν•¨ν•œλ‹€.
    • Command : read(), write(), seek()
    • Raw I/O, direct I/O(buffering, locking 없이), λ˜λŠ” file-system 접근을 λ§ν•œλ‹€.
    • Demand paging 톡해 κ°€μ Έμ˜¨ virtual memory, cluster 에 파일 mapping β‡’ Block λ‹¨μœ„
  • Character device : Character λ‹¨μœ„λ‘œ μ£Όκ³  λ°›λŠ” 것
    • Command : get(), put()

Clocks and Timers

  • Basic function
    • ν˜„μž¬ μ‹œκ°„
    • κ²½κ³Ό μ‹œκ°„
    • X 연산에 μ˜ν•΄ λ°œμƒλœ μ‹œκ°„ T

Clock signal λ§Œλ“€μ–΄ μ‚¬μš©

Nonblocking and Asynchronous I/O

  • Blocking : I/O μš”μ²­μ΄ μ™„λ£Œλ  λ•ŒκΉŒμ§€ ν”„λ‘œμ„ΈμŠ€ 쀑단
  • Nonblocking : I/O μš”μ²­ ν›„ 기닀리지 μ•Šκ³  ν”„λ‘œμ„ΈμŠ€ μ§„ν–‰.
  • Asynchronous : I/O μš”μ²­ ν›„ I/O 처리 μ™„λ£Œλ˜μ—ˆλ‹€κ³  interrupt callback 였면 λ°›λŠ”λ‹€.

image