[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
- No universally accepted definition
- โThe one program running at all times on the computerโis the kernel, part of the operating system
- ๊ทธ์ธ ๋๋จธ์ง๋ system program(ships with the os, but not part of the kernel) ๋๋ application program(all programs not associated with os)์ด๋ค.
- middle ware: ๊ฐ๋ฐ์๋ค์ ์ํด API๋ฅผ ์ ๊ณตํด์ฃผ๋ ๊ณ์ธต, ์ฌ์ฉ์๋ค์ด ๋ณด๋ ๊ฒ๋ณด๋ค ์ถ์ํ๋์ด ์์. ์์: ์ฟผ๋ฆฌ ๋ฑ
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 ์ด๋ค.
- ์ด๋ค ์ฌ๊ฑด์ด ๋ฐ์ํ ๊ฒ์ ์๋ ค์ฃผ๊ธฐ ์ํด CPU๋ฅผ ๊ฐ์๊ธฐ ์ค๋จ์ ์ํด. ๋ง์ฐ์ค๋ฅผ ์์ง์ด๋ฉด ๋ง์ฐ์คI/O์์ CPU์ interrupt๋ฅผ ๊ฒ.
- ๋๋ฐ์ด์ค๋ง๋ค 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 Handling
- CPU๊ฐ interrupt๊ฐ ๊ฑธ๋ฆฌ๋ฉด ์คํํ๋ ์ฝ๋๋ฅผ ๋ฉ์ถ๊ณ ๋ค๋ฅธ ์ฝ๋๋ฅผ ์คํํจ.
๊ทธ๋ฆฌ๊ณ ์๋์ ์ํ๋ก ๋์๊ฐ๊ธฐ ์ํด registers (์ด๋ ํ๋์ register๊ฐ ์๋๋ผ resgister์ ์งํฉ)๋ฅผ ์ ์ฅํจ.
interrupt ๋ฐฉ์.
- polled interrupt system
- interrupt๊ฐ ์ค๋ฉด ํ์ธํ๋ ๋ฐฉ์
- vectored interrupt system
- interrupt์ ๋ฒํธ๊ฐ ๋ฐ๋ผ์ค๋ ๋ฐฉ์(๋๋ถ๋ถ vector ์ฌ์ฉ)
Two interrupt request line
- nonmaskable interrupt: unrecoverable errors(๋ฌด์กฐ๊ฑด ๊ฑธ๋ฆฌ๋ interrupt)
- 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 ์ด๋ผ ํ๊ณ ์ฐ์ ์์๋๋ก ์คํ๋จ.
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
- HDD(Hard Disk Drives): logically divided into tracks, which are subdivided into sectors
- 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(๊ณ์ธต ๊ตฌ์กฐ)
- speed: program
- cost
- 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
Storage-Device Hierarchy
register, cache๋ CPU์์ ๋ด์ฅ๋์ด์๊ณ ๊ฐ์ฅ ๋น ๋ฅด๊ณ ์ฉ๋์ด ์ ์ผ๋ฉฐ ๋น์. ๋ฐ์ผ๋ก ๊ฐ์๋ก ์ฉ๋์ด ํฌ๊ณ ๋๋ฆฌ๋ฉฐ ๊ฐ๊ฒฉ์ด ์.
Working of Modern Computer
DMA(direct memory access)
- Used for high-speed I/O devices
- Device controller transfers blocks of data with out CPU intervention (CPU์ ๋ถํ๋ฅผ ์ค์)
- ํฐ ๋ฐ์ดํฐ๋ฅผ CPU๊ฐ ์ฒ๋ฆฌํ๋ ค๋ฉด ํ๋์ฉ ์ฎ๊ฒจ์ ์ค๋๊ฑธ๋ฆฌ๊ธฐ ๋๋ฌธ์ CPU๊ฐ ๋ชจ๋ ๊ด์ฌํ์ง ์๊ณ ์์๊ณผ ๋๋ง ๊ด์ฌํจ
- 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:
- Increased throughput(์ฒ๋ฆฌ๋) - ์์ ์ ๋ ๋น ๋ฅด๊ฒ ์ฒ๋ฆฌ ๊ฐ๋ฅ
- Economy of scale
- Increased reliability: ์ผ๋ถ ํ๋ก์ธ์๊ฐ ๊ณ์ ์๋ํ์ฌ ์์คํ ์ด ์์ ํ ์ค๋จ๋์ง ์์.
๐Types of Multiprocessor:
- Asymmetric Multiprocessing(๋น๋์นญ ๋ค์ค์ฒ๋ฆฌ) - each processor is assigned a specific task
- Symmetric Multiprocessing(๋์นญ ๋ค์ค์ฒ๋ฆฌ) - each processor performs all tasks
Symmetric Multiprocessing Architecture
Multiple Cores on a Single Chip
Symmetric Multiprocessing Architecture
- Multiple single-core chip
- ๋ ๊ฐ์ ๊ฐ๋ณ ํ๋ก์ธ์๊ฐ ํ๋์ ์์คํ ์์ ๋์ํ๋ฉฐ, ๋ณ๋ ฌ ์ฒ๋ฆฌ ์ฑ๋ฅ์ ํฅ์์ํด.
Multi-chip and Multicore Systems
Dual-Core Design
- Multi-chip and multicore
- Systems containing all chips
- Chassis containing multiple separate systems(ํ๋์ ๋ฌผ๋ฆฌ์ ์ฅ์น ๋ด์ ์ฌ๋ฌ ๊ฐ์ ๋ ๋ฆฝ์ ์ธ ์ปดํจํฐ ์์คํ ์ด ์กด์ฌํ๋ ํํ)
NUMA System
- ์ฌ๋ฌ ๊ฐ์ CPU๊ฐ ๊ฐ๊ฐ ๋ ๋ฆฝ์ ์ธ ๋ฉ๋ชจ๋ฆฌ(memory) ์์ญ์ ๊ฐ์ง๋ฉฐ, ๋ค๋ฅธ CPU์ ๋ฉ๋ชจ๋ฆฌ์ ์ ๊ทผํ ์๋ ์๋ ๊ตฌ์กฐ
- CPU ๊ฐ ๋ฐ์ดํฐ๋ฅผ ๊ณต์ ํ ์ ์๋๋ก Interconnect(์ฐ๊ฒฐ๋ง) ์ด ์กด์ฌ
- Scalability(ํ์ฅ์ฑ)์ด ๋ฐ์ด๋์ง๋ง ์๊ฒฉ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ์ ์ฑ๋ฅ ์ ํ ๋ฅผ ์ด๋ํ ์ ์์
- ex: Server, Data Center etc
Clustered Systems
Clustered Systems
- Multiple systems working together
(์ฆ, ์ฌ๋ฌ ๋์ ์ปดํจํฐ๊ฐ ํ๋์ ๋คํธ์ํฌ๋ก ์ฐ๊ฒฐ๋์ด ๊ณต๋ ์์ ์ ์ํํ๋ ๋ฐฉ์)
โ Features of Clustered Systems
- Storage Sharing
- ์ผ๋ฐ์ ์ผ๋ก Storage Area Network(SAN)๋ฅผ ํตํด ์ฌ๋ฌ ์์คํ ์ด ๋์ผํ ์ ์ฅ์๋ฅผ ๊ณต์ ํจ
- ๋ฐ์ดํฐ ์ผ๊ด์ฑ ์ ์ง ๊ฐ๋ฅ
- Provides a High Availability
- ์์คํ ์ฅ์ ๋ฐ์ ์ ๋ค๋ฅธ ๋ ธ๋๊ฐ ๋์ ์์ ์ ์ํํ์ฌ ์๋น์ค ์ค๋จ์ ๋ฐฉ์ง.
- Asymmetric Clustering has one machine in hot-standby mode
- Symmetric Clustering has multiple nodes running applications, monitoring each other
- Some clutsers are for High-Performance Computing(HPC)
- App must be written to use parallelizaion(๋ณ๋ ฌ ์ฒ๋ฆฌ)
- Distributed Lock Manager(DLM)
- DLM to avoid conflicting operations on shared storage
- ๋ฐ์ดํฐ ๋ฌด๊ฒฐ์ฑ์ ์ ์งํ๊ณ , ๋์ ์ ๊ทผ ๋ฌธ์ ๋ฅผ ๋ฐฉ์ง