Post

[OS] Operating System(1-1): Interrupt, Oranizaion, Architecture

[OS] Operating System(1-1): Interrupt, Oranizaion, Architecture

๐Ÿ€ ์šด์˜์ฒด์ œ ์ „๊ณต ์ˆ˜์—… ์ •๋ฆฌ

Operatrion System(OS)

์—ฌ๋Ÿฌ ์„œ๋น„์Šค๋“ค์„ ์œ ์ €๋“ค๊ณผ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์„ ํ•˜๋“œ์›จ์–ด๊ฐ€ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์—ญํ• 

Definition of OS


  • ๋ณด๋Š” ๊ด€์ ์— ๋”ฐ๋ผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์Œ (์‚ฌ์šฉ์ž <-> ๊ฐœ๋ฐœ์ž)
  • ์šด์˜์ฒด์ œ๊ฐ€ ์žˆ๋Š” ์ด์œ : ํ•˜๋‚˜ ์ปดํ“จํ„ฐ๋งˆ๋‹ค ํ•˜๋‚˜์˜ ํ”„๋กœ๊ทธ๋žจ๋งŒ ์ž‘๋™ํ•˜์ง€ ์•Š์Œ.
    • ์—ฌ๋Ÿฌ ํ”„๋กœ๊ทธ๋žจ์„ ํ•˜๋“œ์›จ์–ด ๊ฐ™์€ ์ธํ”„๋ผ๋ฅผ ๊ฐ€์ง€๊ณ  ํšจ์œจ์ ์œผ๋กœ ๋Œ๋ฆฌ๊ธฐ์œ„ํ•ด ์šด์˜์ฒด์ œ๊ฐ€ ํ•„์š”.
    • ์ž‘์€ ๋ฉ”๋ชจ๋ฆฌ(RAM)๋งŒ ๊ฐ€์ง€๊ณ ๋„ ์—ฌ๋Ÿฌ ํ”„๋กœ๊ทธ๋žจ์„ ๋Œ๋ฆด ์ˆ˜ ์žˆ์Œ.
  • Mobile devices like smartphones and tablets are resource poor, optimized for usability and battery life
    ๋ชจ๋ฐ”์ผ์€ ์„ฑ๋Šฅ์ด ๋” ์ž‘์œผ๋‹ˆ resource poor ํ•˜๊ณ , ๋ฐฐํ„ฐ๋ฆฌ๋ฅผ ์ž˜ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์šด์˜์ฒด์ œ๊ฐ€ ์—ฌ๊ธฐ์— ๋งž์ถฐ ๊ฐœ๋ฐœ๋จ.
  • ์‹ฌ์ง€์–ด ๊ฐ€์ „์ œํ’ˆ ๋“ฑ์—๋„ CPU๊ฐ€ ์žˆ๊ณ  OS๋„ ์žˆ์Œ. OS์˜ ์‹œ๋ฐœ์ ์€ ๊ตฐ์‚ฌ์šฉ์ด์—ˆ์Œ.

Concept of OS


  1. No universally accepted definition
  2. โ€œThe one program running at all times on the computerโ€is the kernel, part of the operating system
  3. ๊ทธ์™ธ ๋‚˜๋จธ์ง€๋Š” system program(ships with the os, but not part of the kernel) ๋˜๋Š” application program(all programs not associated with os)์ด๋‹ค.
  4. middle ware: ๊ฐœ๋ฐœ์ž๋“ค์„ ์œ„ํ•ด API๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ๊ณ„์ธต, ์‚ฌ์šฉ์ž๋“ค์ด ๋ณด๋Š” ๊ฒƒ๋ณด๋‹ค ์ถ”์ƒํ™”๋˜์–ด ์žˆ์Œ. ์˜ˆ์‹œ: ์ฟผ๋ฆฌ ๋“ฑ

Computer System Organization

Computer System Organization

  • ๊ฐ๊ฐ system bus๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๊ณ , ์ด๋ฅผ ํ†ตํ•ด ๋‹ค ์—ฐ๊ฒฐ์ด ๋˜์–ด ๋™์‹œ์—(Concurrent) ์šด์˜์ด ๋œ๋‹ค.
  • Concurrent ๊ณผ์ •์—์„œ ์ถฉ๋Œ์€ ํ”ผํ•  ์ˆ˜ ์—†๋‹ค. ํŠนํžˆ ๋ฉ”๋ชจ๋ฆฌ์— ์ ‘๊ทผํ•  ๊ฒฝ์šฐ์— ์ถฉ๋Œ์€ ๋นˆ๋ฒˆํ•ด์„œ ๋ฉ”๋ชจ๋ฆฌ ์ ‘๊ทผ์€ ๋А๋ฆด ์ˆ˜ ๋ฐ–์— ์—†์Œ.
  • I/O devices and the CPU can execute Concurrently
  • Local Buffer ๋Š” I/O device๋ฅผ ์ œ์–ดํ•˜๊ธฐ์œ„ํ•œ ์ปจํŠธ๋กค๋Ÿฌ ์ด๋‹ค.
    • ํ•จ์ˆ˜ ๋˜๋Š” ํŠน์ • ์ฝ”๋“œ ๋ธ”๋ก ๋‚ด์—์„œ ์„ ์–ธ๋œ ์ž„์‹œ ์ €์žฅ ๊ณต๊ฐ„์œผ๋กœ, ์Šคํƒ(stack) ๋ฉ”๋ชจ๋ฆฌ์— ์ €์žฅ๋จ.
  • Each device controller type has an operating system device driver to manage it
  • CPU moves data from/to main memory to/from local buffers. (์ปดํ“จํ„ฐ ์‹œ์Šคํ…œ์—์„œ ์–ด๋–ค ๊ณ„์‚ฐ์ด๋“  CPU๋ฅผ ํ†ตํ•ด์„œ ์ด๋ฃจ์–ด ์ง„๋‹ค. ๋ฐ์ดํ„ฐ์˜ ์ด๋™์กฐ์ฐจ.)
  • Device controller informs CPU that it has finished its operation by causing an interrupt.

๊ทธ๋Ÿผ CPU๋“ค์ด ๋ชจ๋“  ์ผ์— ์–ด๋–ป๊ฒŒ ๊ด€์—ฌํ•˜๋Š”๊ฐ€??

๊ทธ๊ฑธ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š”๊ฒŒ Interrupt ์ด๋‹ค.

Interrupt


  • Interrupt๋Š” โ€˜๋ฐฉํ•ดํ•˜๋‹คโ€™๋ผ๋Š” ๋œป์ฒ˜๋Ÿผ CPU๊ฐ€ ํ•˜๋Š” ํ–‰์œ„๋ฅผ ๋ฐฉํ•ดํ•ด์„œ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ผ์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ.

Function of Interrupt


  • Interrupt transfers control to the interrupt service routine generally,
    through the interrupt vector, which contains the addresses of all the service routines
    • ์–ด๋–ค ์‚ฌ๊ฑด์ด ๋ฐœ์ƒํ•œ ๊ฒƒ์„ ์•Œ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด CPU๋ฅผ ๊ฐ‘์ž๊ธฐ ์ค‘๋‹จ์„ ์‹œํ‚ด. ๋งˆ์šฐ์Šค๋ฅผ ์›€์ง์ด๋ฉด ๋งˆ์šฐ์ŠคI/O์—์„œ CPU์— interrupt๋ฅผ ๊ฒ€.
      ๊ทธ๋Ÿผ CPU๊ฐ€ ๋ฉˆ์ถ”๊ณ  ๋ณ€๊ฒฝ๋œ ๊ฒƒ์„ ๋ฐ˜์˜. ์ด ๊ณผ์ •์˜ ์ฝ”๋“œ ๊ฐ€ interrupt service routines ์ด๋‹ค.
  • ๋””๋ฐ”์ด์Šค๋งˆ๋‹ค interrupt๊ฐ€ ์žˆ๋Š”๋ฐ, ๊ฐ interrupt๋ฅผ ๊ตฌ๋ณ„ํ•˜๊ธฐ ์œ„ํ•ด interrupt vector ๊ฐ€ ์žˆ๋‹ค.(์ฆ‰, interrupt์˜ index ์—ญํ• )
  • A trap or exception is a software-generated interrupt.
  • OS is interrupt driven.
    • interrupt์˜ ์ข…๋ฅ˜๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์•„์„œ ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง„๋‹ค. vector์—์„œ ๋ฒˆํ˜ธ๊ฐ€ ํ•˜๋‚˜๋งŒ ์ฃผ์–ด์ง€๋Š” ๊ฒŒ ์•„๋‹ˆ๋ผ, ๊ทธ ์ฃผ์†Œ์˜ table์ด ๋˜ ์žˆ๋‹ค.(ex: ์™ธ๊ณผ์—๋„ ์…ฉํ˜•์™ธ๊ณผ, ์ผ๋ฐ˜์™ธ๊ณผ ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ)

CPU๊ฐ€ interrupt๊ฐ€ ๊ฑธ๋ฆฐ์ง€ ์–ด๋–ป๊ฒŒ ์•„๋Š”๊ฐ€?

  • The CPU hardware has a wire called the interrupt-request line that the CPU senses after executing every instruction. (interrupt๋Š” ๋Œ€๋žต 1์ดˆ์— 2์ฒœ๋ฒˆ ์ •๋„ ์ด๋ฃจ์–ด ์ง„๋‹ค.)

interrupt_timeline

interrupt_timeline

Interrupt Handling


  • CPU๊ฐ€ interrupt๊ฐ€ ๊ฑธ๋ฆฌ๋ฉด ์‹คํ–‰ํ•˜๋˜ ์ฝ”๋“œ๋ฅผ ๋ฉˆ์ถ”๊ณ  ๋‹ค๋ฅธ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•จ.
    ๊ทธ๋ฆฌ๊ณ  ์›๋ž˜์˜ ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ€๊ธฐ ์œ„ํ•ด registers (์–ด๋А ํ•˜๋‚˜์˜ register๊ฐ€ ์•„๋‹ˆ๋ผ resgister์˜ ์ง‘ํ•ฉ)๋ฅผ ์ €์žฅํ•จ.

interrupt ๋ฐฉ์‹.

  1. polled interrupt system
    • interrupt๊ฐ€ ์˜ค๋ฉด ํ™•์ธํ•˜๋Š” ๋ฐฉ์‹
  2. vectored interrupt system
    • interrupt์— ๋ฒˆํ˜ธ๊ฐ€ ๋”ฐ๋ผ์˜ค๋Š” ๋ฐฉ์‹(๋Œ€๋ถ€๋ถ„ vector ์‚ฌ์šฉ)

Two interrupt request line

  1. nonmaskable interrupt: unrecoverable errors(๋ฌด์กฐ๊ฑด ๊ฑธ๋ฆฌ๋Š” interrupt)
  2. maskable interrupt: can be turned off(์•ˆ๋ฐ›์•„๋„ ๋˜๋Š” interrupt)
  • Interrupt chaining: each element in the interrupt vector points to the head of a list of interrupt handlers.
    • vector์˜ ํฌ๊ธฐ๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
  • interrupt์˜ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ์žˆ๋Š”๋ฐ interrupt priority level ์ด๋ผ ํ•˜๊ณ  ์šฐ์„ ์ˆœ์œ„๋Œ€๋กœ ์‹คํ–‰๋จ.

alt text

Interrupt-drive I/O Cycle instruction์ค‘์— sensing์„ ํ†ตํ•ด interrput ์—ฌ๋ถ€ ํ™•์ธ interrupt๋Š” OS์˜ multitasking๋“ฑ์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ์ดˆ

Storage Structure


  • main memory: only large storage media that the CPU can access directly
    • Random access
    • Typically volatile(ํœ˜๋ฐœ์„ฑ)
    • Typically random-access memory in the form of Dynamic Random-access Memory(DRAM)
  • Secondary storage: extension of main memory that provides large nonvolatile(๋น„ํœ˜๋ฐœ์„ฑ) storage capacity
    1. HDD(Hard Disk Drives): logically divided into tracks, which are subdivided into sectors
    2. NVM(Non-volatile memory) devices = SSD: faster than hard disk, Nonvolatile, Varios technologies, Becoming more popular(as capacity and performance increases, price drops).

Storage Definitions and Notation


  • bit: The basic unit of computer storage.
  • byte: Is 8bits, the smallest convenient chunk of storage
  • word: size of CPUโ€™s register(ex: 1word = 8byte in 64bits CPU) (octec = 8 bit = 1 byte)

Stroage Hierarchy


Storage systems organized in hierarchy(๊ณ„์ธต ๊ตฌ์กฐ)

  1. speed: program
  2. cost
  3. volatility
  • Caching: copying information into faster storage system
    • Main memory can be viewed as a cache for secondary storage
  • Device Driver: For each device controller to manage I/O
    • Provides uniform interface b/w controller and kernel

alt text

Storage-Device Hierarchy

register, cache๋Š” CPU์•ˆ์— ๋‚ด์žฅ๋˜์–ด์žˆ๊ณ  ๊ฐ€์žฅ ๋น ๋ฅด๊ณ  ์šฉ๋Ÿ‰์ด ์ ์œผ๋ฉฐ ๋น„์Œˆ. ๋ฐ‘์œผ๋กœ ๊ฐˆ์ˆ˜๋ก ์šฉ๋Ÿ‰์ด ํฌ๊ณ  ๋А๋ฆฌ๋ฉฐ ๊ฐ€๊ฒฉ์ด ์Œˆ.

alt text

Working of Modern Computer

DMA(direct memory access)


  1. Used for high-speed I/O devices
  2. Device controller transfers blocks of data with out CPU intervention (CPU์˜ ๋ถ€ํ•˜๋ฅผ ์ค„์ž„)
    • ํฐ ๋ฐ์ดํ„ฐ๋ฅผ CPU๊ฐ€ ์ฒ˜๋ฆฌํ•˜๋ ค๋ฉด ํ•˜๋‚˜์”ฉ ์˜ฎ๊ฒจ์„œ ์˜ค๋ž˜๊ฑธ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— CPU๊ฐ€ ๋ชจ๋‘ ๊ด€์—ฌํ•˜์ง€ ์•Š๊ณ  ์‹œ์ž‘๊ณผ ๋๋งŒ ๊ด€์—ฌํ•จ
  3. Only one interrupt is generated per block, not per byte

Computer-System Architecture


  • Most systems use a single general-purpose processor
    • Most systems have special-purpose processors as well
  • Multiprocessors systems growing in use and importance
    • Known as parallel systems(๋ณ‘๋ ฌ ์‹œ์Šคํ…œ), tightly-coupled systems(๋ฐ€๊ฒฐํ•ฉ ์‹œ์Šคํ…œ)

โœ…Advantages of Multiprocessor:

  1. Increased throughput(์ฒ˜๋ฆฌ๋Ÿ‰) - ์ž‘์—…์„ ๋” ๋น ๋ฅด๊ฒŒ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ
  2. Economy of scale
  3. Increased reliability: ์ผ๋ถ€ ํ”„๋กœ์„ธ์„œ๊ฐ€ ๊ณ„์† ์ž‘๋™ํ•˜์—ฌ ์‹œ์Šคํ…œ์ด ์™„์ „ํžˆ ์ค‘๋‹จ๋˜์ง€ ์•Š์Œ.

๐Ÿ“Types of Multiprocessor:

  1. Asymmetric Multiprocessing(๋น„๋Œ€์นญ ๋‹ค์ค‘์ฒ˜๋ฆฌ) - each processor is assigned a specific task
  2. Symmetric Multiprocessing(๋Œ€์นญ ๋‹ค์ค‘์ฒ˜๋ฆฌ) - each processor performs all tasks

Symmetric Multiprocessing Architecture

Multiple Cores on a Single Chip


alt text

Symmetric Multiprocessing Architecture

  • Multiple single-core chip
    • ๋‘ ๊ฐœ์˜ ๊ฐœ๋ณ„ ํ”„๋กœ์„ธ์„œ๊ฐ€ ํ•˜๋‚˜์˜ ์‹œ์Šคํ…œ์—์„œ ๋™์ž‘ํ•˜๋ฉฐ, ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ด.

Multi-chip and Multicore Systems


alt text

Dual-Core Design

  • Multi-chip and multicore
  • Systems containing all chips
    • Chassis containing multiple separate systems(ํ•˜๋‚˜์˜ ๋ฌผ๋ฆฌ์  ์žฅ์น˜ ๋‚ด์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋…๋ฆฝ์ ์ธ ์ปดํ“จํ„ฐ ์‹œ์Šคํ…œ์ด ์กด์žฌํ•˜๋Š” ํ˜•ํƒœ)

NUMA System


alt text

  • ์—ฌ๋Ÿฌ ๊ฐœ์˜ CPU๊ฐ€ ๊ฐ๊ฐ ๋…๋ฆฝ์ ์ธ ๋ฉ”๋ชจ๋ฆฌ(memory) ์˜์—ญ์„ ๊ฐ€์ง€๋ฉฐ, ๋‹ค๋ฅธ CPU์˜ ๋ฉ”๋ชจ๋ฆฌ์— ์ ‘๊ทผํ•  ์ˆ˜๋„ ์žˆ๋Š” ๊ตฌ์กฐ
  • CPU ๊ฐ„ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋„๋ก Interconnect(์—ฐ๊ฒฐ๋ง) ์ด ์กด์žฌ
  • Scalability(ํ™•์žฅ์„ฑ)์ด ๋›ฐ์–ด๋‚˜์ง€๋งŒ ์›๊ฒฉ ๋ฉ”๋ชจ๋ฆฌ ์ ‘๊ทผ์€ ์„ฑ๋Šฅ ์ €ํ•˜ ๋ฅผ ์ดˆ๋ž˜ํ•  ์ˆ˜ ์žˆ์Œ
  • ex: Server, Data Center etc

Clustered Systems


alt text

Clustered Systems

  • Multiple systems working together
    (์ฆ‰, ์—ฌ๋Ÿฌ ๋Œ€์˜ ์ปดํ“จํ„ฐ๊ฐ€ ํ•˜๋‚˜์˜ ๋„คํŠธ์›Œํฌ๋กœ ์—ฐ๊ฒฐ๋˜์–ด ๊ณต๋™ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ์‹)

โœ…Features of Clustered Systems

  1. Storage Sharing
    • ์ผ๋ฐ˜์ ์œผ๋กœ Storage Area Network(SAN)๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ ์‹œ์Šคํ…œ์ด ๋™์ผํ•œ ์ €์žฅ์†Œ๋ฅผ ๊ณต์œ ํ•จ
    • ๋ฐ์ดํ„ฐ ์ผ๊ด€์„ฑ ์œ ์ง€ ๊ฐ€๋Šฅ
  2. Provides a High Availability
    • ์‹œ์Šคํ…œ ์žฅ์•  ๋ฐœ์ƒ ์‹œ ๋‹ค๋ฅธ ๋…ธ๋“œ๊ฐ€ ๋Œ€์‹  ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜์—ฌ ์„œ๋น„์Šค ์ค‘๋‹จ์„ ๋ฐฉ์ง€.
    • Asymmetric Clustering has one machine in hot-standby mode
    • Symmetric Clustering has multiple nodes running applications, monitoring each other
  3. Some clutsers are for High-Performance Computing(HPC)
    • App must be written to use parallelizaion(๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ)
  4. Distributed Lock Manager(DLM)
    • DLM to avoid conflicting operations on shared storage
    • ๋ฐ์ดํ„ฐ ๋ฌด๊ฒฐ์„ฑ์„ ์œ ์ง€ํ•˜๊ณ , ๋™์‹œ ์ ‘๊ทผ ๋ฌธ์ œ๋ฅผ ๋ฐฉ์ง€
This post is licensed under CC BY 4.0 by the author.