득이공간

[운영체제] 1장. OS 소개 (1) 본문

CS/운영체제

[운영체제] 1장. OS 소개 (1)

쟁득 2024. 2. 4. 22:24
해당 게시물은 조진성 교수님의 '운영체제' 강의를 수강하며
학습한 내용을 개인적으로 정리한 글입니다.

📌 목차 - 1장. OS 소개

1-1. Introduction (1)
1-2. Operating System Structures (2)


📌 1-1. Introduction

* 컴퓨터

- 컴퓨터 HW 위에 컴퓨터 SW가 수행되는 장치


* 컴퓨터 HW란

- CPU, MEMORY, I/O장치로 구성되어있는 장치


* 컴퓨터 예시

- Sever (Computer), Personal Computer, Embedded Computer/System


* 운영체제 요약

- 컴퓨터 HW 자원을 관리해주는 시스템
- CPU, MEMORY, I/O장치 관리


* PC OS

- windows, linux, mac


* Sever OS

- unix(5년전까지), linux(오픈소스 SW, 클라우드 시스템)


* Embedded OS

- raspberrypi, linux(android, 스마트 TV, 네트워크 프린터 등등)


* Programming Language
- Sever : Java
- PC : C++, C#
- Embedded System : C

 

* Computer Hardware Architecture
- CPU, Memory, I/O device
- 위 세 가지 사이에는 한 대만 다니는 버스에 데이터가 타서 이동한다.
- CPU, 'I/O controller(Adapter) - 작은 컴퓨터, I/O device', Memory
- 1024 : 2^10
- system program : 컴퓨터를 활용하기 위해서 운영체제가 만들어놓은 프로그램, 운영체제를 설치하면 같이 설치되는 프로그램. ex. 윈도우즈 탐색기
- application program : 특정 목적으로 실행시키는 프로그램


* 운영체제

- 컴퓨터 하드웨어(Resource - CPU, Memory, I/O devices)를 관리해주는 소프트웨어
- 1. 프로그램들이 하드웨어를 쉽게 사용할 수 있는 인터페이스(system call) 제공
- 2. 컴퓨터 하드웨어가 효율적으로 사용될 수 있도록 관리


* Class를 member와 member function으로 표현하는 것이 "abstraction"이고 member function만 알면 내부 동작을 몰라도 사용할 수 있다는 개념이 "encapsulation"이다.


* SW which manages 'Computer HW' resources for
- 1. convenience
- 2. efficiency


* OS is a resource manager
- Abstraction
- Sharing (Time/Space multiplexing)
- Protection
- Fairness
- Performance


* Definition in textbook
- Resource allocator
- Control program
- Kernel


* Ubuntu 운영체제는 Linux Kernel과 System Program들을 조합해서 PC에 설치할 수 있도록 만든 배포판이다.

* 운영체제 커널은 메모리에 상주해서 항상 실행되는 프로그램이다.


* CPU
- 1. ALU (Arithmetic and Logical Unit)
- PC : CPU는 Program Counter에 저장되어있는 명령어를 읽어서 Instruction Register에 넣는다. 로딩
- IR : CPU는 Instruction Register에 있는 명령어를 수행한다.
- 2. CU (Control Unit)
- SP : 임시적인 Stack의 Top을 가리키는 register. Stack Pointer
- PSW : CPU의 상태를 표현하는 register. Program Status Word
- 3. MMU (Memory Management Unit)
- General purpose registers


* Instructions
- Arithmetic : add, subtract, multiply, divide, ...
- Logical : and, or, xor, not, shift, ...
- Control Flow : goto, if, call,, return, ...
- Data : load, store, move, input, output, ...


* Compile : C -> Assembly


* Bootstrapping in Linux
- 1. The CPU initializes itself.
- 2. BIOS (Basic Input/Output System) / UEFI (Unified Extensible Firmware Interface)
- 3. Boot Loader LILO/GRUB
- MBR (Master Boot Record) in BIOS.
- ESP (Efi System Partition) in UEFI.
- 4. BIOS/UEFI loads and transfers control to LILO/GRUB.
- 5. LILO/GRUB loads the compressed kernel.
- 6. compressed kernel decompresses itself.


* Firmware

- Hardware에 포함된 Software 또는 그 중간 것, rom에 저장되어 동작하고 수정하기 어려운 software

 

* CPU - Instruction Set Architecture (ISA)
- CISC vs RISC
- RISC : Instruction의 Set 수를 줄여서 CPU Clock도 높이고 캐시 메모리로 인해서 성능이 비약적으로 향상됐다.
- Intel, SPARC, MIPS, PowerPC, ARM, Alpha, ...


* CPU - Pipelining
- 1. Fetch : 메모리에서 IR로 명령어를 가져오는 것
- 2. Decode : IR에 있는 명령어가 무엇인지 알아내는 것
- 3. Excute : HW 로직에서 실행하는 것
- 4. Write Back, etc. : 결과를 다시 레지스터에 저장하는 것


* CPU - Instruction-Level Parallelism (ILP)
- Superscalar vs VLIW
- Simultaneous multithreading : 하나의 프로그램 안에서 여러개의 명령어
- Multi-core : 여러개의 프로그램


* Concurrent(동시) / 하나의 코어에서 여러개의 프로그램이 번갈아가면서 동시에 동작하는 것 vs Parallel(병행) / 여러개의 코어에서 여러개의 프로그램이 동시에 동작하는 것 vs Simultaneous(동시 또는 병행)


* SMP (Symmetric multiprocessing architecture)

- 메인 메모리를 여러개의 CPU들이 공유하는 방식


* NUMA (Non-Uniform Memory Access) multiprocessing architecture

- 각 CPU마다 메인 메모리를 가지고 있는 방식 / SuperComputer


* Clustered System Architecture

- 서버들이 가지고 있는 구조
- Parallel 병렬 시스템 (컴퓨터 내부) : 보드 하나에 여러 개의 CPU가 메모리를 공유하는 구조
- Distributed 분산 시스템 : 여러 대의 컴퓨터가 네트워크를 통해 연결되어있는 구조


* I/O request via I/O instruction
- CPU 명령어로 I/O controller에 device 작업을 요청한다.
- I/O contorller도 작은 컴퓨터로써 IR & DR 을 갖고 있다.


* I/O Method
- Interrupt : 이벤트(키 입력 등)가 발생했음을 CPU에게 알린다.
* DMA (Direct Memory Access) : CPU가 메모리를 사용하고 있지 않을 때(I/O 장치 입력을 통한 interrupt 발생) Disk Controller와 메모리의 버스를 연결해주는 것


* Interrupt-driven I/O cycle
- 1. CPU - device driver initiates I/O
- 2. I/O controller - initiates I/O
- 3. I/O controller - input ready, output complete, or error generates interrupt singal
- 4. CPU - receiving interrupt, transfers control to interrupt handler
- 5. CPU - interrupt handler processes data, returns from interrupt
- 6. CPU - resumes processing of interrupted task


* interrupt가 끝나고나면 운영체제가 실행된다.


* Synchronous/Blocking

- 요청하고 기다리는 것

* Asynchronous/Non-blocking

- 요청하고 다시 자기 할 일을 하고 있는 것


* Interrupt 종류
- Interrupt (Hardware Interrupt) : HW device에서 이벤트가 발생 (asynchronous)
- Trap (Software Interrupt) : application processes에서 이벤트가 발생 (synchronous)
- Fault (Exception) : CPU 자기 자신에서 이벤트 발생 (synchronous)


* I/O의 동작은 I/O Controller가 CPU에서 내린 명령어를 처리한다.

* 근데 이 작업이 느리기 때문에 CPU는 다른 일을 처리하고 있는다.

 

* ROM

- 비휘발성
* RAM

- 휘발성
* SRAM

- 캐시 메모리에 사용된다. 값을 계속 기억한다. 빠르고 비싸다.
* DRAM

- 메인 메모리에 사용된다. 주기적으로 값을 유지해야한다. 값 싸서 메인 메모리에 쓰인다.


* Memory Hierarchy
값 비싼 순서 (성능이 크고 용량이 작다.)
- register
- cache : CPU와 Memory 사이에 존재하는 임시 저장장치
- main memory
- solid-state disk (sdd) : Flash Memory
- hard disk (hdd)
- optical disk
- magnetic tapes : 언론사, 은행 등에서 주로 사용된다.


* 컴퓨터 소프트웨어는 Locality 특성이 있다.
- 프로그램 실행의 대부분(80퍼센트)이 전체 프로그램의 20프로에서 이루어진다.
* 캐시 메모리는 100퍼센트 하드웨어에서 동작한다. (운영체제가 관여하지 않는다.)


* Caching
- Cache management policy : Write-through vs Write-back(얘가 성능이 더 좋다.)
- Cache coherency


* HDD
- platters
- surfaces
- tracks
- sectors
- cylinders
- arm
- head
- 여러개의 platter, surface에 똑같은 track을 이은 것을 Cylinder라고 한다.


* SSD
- HOST
- Flash Controller : ARM Core, SRAM, NOR
- NAND Falsh Memory
- Flash Translation Layer : Processing Unit


* Hardware protection
- CPU protection : 운영체제가 하나의 프로그램이 CPU를 독차지하지 못하도록 막는 방법. Timer (periodic interrupt, 10ms in Linux)
- Memory protection : 운영체제가 프로그램이 자기가 참조할 수 없는 메모리를 참조하면 Protection fault를 발생시킨다. (E.g. segmentation violation in Linux)
- I/O protection : 프로그램이 마음대로 I/O 장치를 쓰지 못하도록 막는 것이다. I/O장치는 운영체제만 사용해야한다.
Dual mode operation in CPU
Privileged instructions only in kernel mode
Unprivileged instructions in user mode


* 프로그램은 파일시스템에 존재하는 실행파일이다.
* 프로그램이 실행돼서 메모리에서 수행되는 상황이 프로세스다.
* I/O 장치에 내리는 명령은 user mode에서는 실행할 수 없고 kernel mode에서만 실행할 수 있다.

 

* System Call
- function call


* OS take control of the system
- Bootstrapping
- System calls
- Interrupts


* HW->interrupts->system call->trap


* Computer History
- 1st Generation (1945-1955) : Eniac, John Von Newman
- 2nd Generation (1955-1965) : MainFrame, Batch system - 프로그램이 하나씩 실행된다.
- 3rd Generation (1965-1980) : Computer Architecture, Multiprogramming systems - 여러 개의 프로그램을 실행한다.
Time-sharing systems - 여러 개의 프로그램을 돌아가면서 실행한다.
- 4th Generation (1980-) : Personal Computer, GUI, Multimedia, Internet & Web, Networked / Distributed, etc.


* Computing Environments
- Traditional computing : Mainframe system, Desktop system
- Mobile computing : Hand-held system
- Real-time embedded computing : Real-time system (시간 제약 조건이 있는 시스템), Embedded system
- Client-server computing : Large-scale server in data center, Clustered server - Parallel + Distributed + Storage
- Peer-to-peer computing : Discovery protocol, Napster, Gnutella, VoIP, etc.
- Cloud computing : Virtual Machine, Infrastructure as a Service (IaaS), Platform as a Service (PaaS), Software as a Service (Saas)
- Distributed computing : Hadoop, Spark


* Virtualization

- 운영체제를 하나씩 사용하기에는 하드웨어가 아깝다. -> 이에 대한 해결책

 

* Java
- JVM executes "platform-neutral byte-codes"
- JIT (Just-In-Time) compilers increase performance


* OS History
- IBM OS/360 : Multiprogramming
- MIT CTSS (Compatible Time-Sharing System)
- MIT, Bell Labs, GE, MULTICS (MULTiplexed Information and Computing Service)


* OS History : Unix
- Unix was born in 1969 : 세계 최초로 High Level Programing Language(C)로 만든 OS다. System V 계열 / BSD 계열, XENIX - PC에 설치되는 첫 UNIX, SunOS->Solaris, MACH->NeXT Step(이 회사의 마지막 사장이 스티브 잡스다.)

* OS History : Windows

* OS History : Linux
- 1991 : Comletely free Operating System - Linux/GNU
- 1995 : Linux is more and more popular on server systems
- 2000 : Linux is more and more popular on embedded systems
- 2008 : Linux is more and more popular on mobile devices (PDA)
- 2010 : Linux is more and more popular on phones


* OS Taxonomy
- Mainframe systems : CTS, MULTICS, IBM MVS, VM
- Desktop systems : DOS, Windows, MacOS, Unix/Linux
- Distributed systems : Amoeba(Vrije Univ.), Locas(UCLA), Grapevine(Xerox), V(Stanford), Eden(U. of Washington), Chorus/Nucleus(Inria)
- Embedded systems : VxWorks, FreeRTOS, NuttX, Vertex, pSOS, OSE, Windows-CE, Embedded Linux, Company-proprietary OS (Cisco, Qualcomm, Palm, Cellvic)
- Real-time systems : Real-Time Linux, Spring(U. of Massachusetts), HARTS(U. of Michigan), MARUTI(U. of Maryland)


'CS > 운영체제' 카테고리의 다른 글

[운영체제] 4장. I/O Device 관리  (1) 2024.02.24
[운영체제] 3장. Memory 관리  (1) 2024.02.24
[운영체제] 2장. CPU 관리  (0) 2024.02.07
[운영체제] 1장. OS 소개 (2)  (0) 2024.02.07