컴퓨터의 요소
- 하드웨어 : 눈에 보이고 만질 수 있는 모든 장치(cpu, 메모리, I/O장치로 구성), 기본 계산용 자원을 제공
- 운영체제 : 자원할당자로 불리며 다양한 사용자를 위해 다양한 API간의 HW사용을 제어하고 조정
(응용프로그램은 HW와 직접 access하지 못하고 OS를 통하여 연결 또는 access가 가능하다)
(OS는 응용프로그램에 service를 제공하고 HW를 제어할 수 있어야함)
(OS를 사용하는 이유는 질서유지를 위해, HW를 보호하기 위해서다) - 응용프로그램 : 컴파일러, 데이터베이스, 오피스 등의 비즈니스 프로그
- 유저 : 사용하는 사람, 기계, 컴퓨터(꼭 사람이 아님)
- 네트워크 : 위 네 가지를 같이 사용하기위해 사용
운영체제란 무엇인가?
between user/appliration and H/W
- 사용자와 컴퓨터 사이의 매개체 역할을 하며, 사용자에게 프로그램을 수행할 수 있는 환경을 제공해주고컴퓨터를 효율적으로 이용할 수 있게 해준다.
:많은 사람들이 동시에 사용할 수 있는 중, 대형 컴퓨터의 환경에서도 잘 돌아가야한다. 임베디드 시스템은 운영체제가 없을 수도 있지만 전용의 작은 OS가 있을 수 있다.
자원 할당자로서 HW와, SW들의 자원을 조정하고 할당하고, 프로그램의 실행과 I/O장치의 작동을 제어한다. - 우리가 사용하는 운영체제는 규모가 크다. 용도와 목적에 따라 운영체제에 필요한 구조가 달라질 수 있음.
OS Definitions
- Resource allocator – manages and allocates resources. Resource allocator(자원할당자)
- Control program – controls the execution of user programs and operations of I/O devices.control program(제어프로그램)
- Kernel – the one program running at all times(all else being application programs).kernel(os가 가지는 sw적 기능,항상 수행되는 프로그램
Computer-system Operation
- I/O devices and the CPU can execute concurrently i/o와 cpu는 동시동작함
- Each device controller is in charge of a particular device type
- Each device controller has a local buffer
- Each device controller type has an operating system device driver to manage it.devece controller는 각 device들을 제어, 각 buffer를 가짐, os가 device dirver로 제어함
- CPU moves data from/to main memory to/from local buffersbuffer 와 memory 사이의 데이터들을 cpu가 처리함
- I/O is from the device to local buffer of controller
- Device controller informs CPU that it has finished its operation by causing an interruptdevice cotroller는 인터럽트 형태로 cpu에게 정보를 제공함
Interrupts 제어를 주고 받음
computer startup
bootstrap program is loaded at power-up or reboot
- Typically stored in ROM or EpROM, generally known as firmware
- Initializes all aspects of system
- Loads operatig sysyem kernel and starts execution
Interrupt Handling
- The operating system preserves the state of the CPU by storing registers and the program counter. : cpu는 하고 있던 일을 저장 한 후 interrupt 처리 후 다시 하던일을 하게 해줌
- Determines which type of interrupt hasoccurred:
1.polling : 다시 살펴봄
2.vectored interrupt system : 점프 - Separate segments of code determinewhat action should be taken for each type of interrupt(ISR: interrupt service routine) ** interupt를 처리하기 위한 작은 프로그램을 ISR이라고 함**
torage 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 nonvolatilestorage capacity
- Hard Disk Drives(HDD) - rigid metal or glass platters covered with magnetic recording material- Disk surface is logically divided into tracks, which are subdivided into sectors- The disk controller determines the logical interaction between the device and the computer
- Non-volatile memory(NVM) devices – faster than hard disks, nonvolatile- Various technologies- Becoming more popular as capacity and performance increases, price drops
Storage Hierarchy
- Storage systems organised in hierarchy
- Speed
- 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 between controller and kernel
현대 컴퓨터의 일반적인 처리 방식
(이미지)
- DMA: direct memory access
- 비: 폰노이만형 컴퓨터 : 데이터 처리의 고속화,고도화를 위해 병렬 처리하는 것이 주된 목표, 명령과 데이터를 분리한다.
- 폰노이만형 컴퓨터 : 하나의 메모리에 하나의 버스를 이용하여 데이터와 명령을 같은 곳에 두고 같이 읽어온다. **이 위에와는 다르게 data,program을 다르게 처리하여 고속화 시킨 방법도 있음. (havart)
Computer-System Architecture : CPU같은 물리적인 ,프로세스: 프로그램 실행 단위
● Most systems use a single general-purpose processor
- Most systems have special-purpose processors as well ● Multiprocessors systems growing in use and importance
- Also known as parallel systems, tightly-coupled systems
- Advantage include:
- Increased throughput
- Economy of scale
- Increased reliability – graceful degradation or fault tolerance
- Two types:
- Asymmetric Multiprocessing – each processor is assigned a specie task.
- 비대칭형 다중처리: 각 프로세서는 서로 다른 업무를 분담한다.
- Symmetric Multiprocessing – each processor performs all tasks.
- 대칭형 다중처리: 가장 많이 사용하고 있는 방식으로 각 프로세서는 대등하며, 같은 수준의 일을 한다.
● 다중 프로세서의 경우 다수의 프로세서가 하나의 메인 메모리를 사용하기 때문에상대적으로 효율이 떨어진다. (메모리 접근 버스 사용 때문)
A Dual-Core Design
● Multi-chip and multi-core
● Systems containing all chips- Chassis containing multiple separate systems
Non-Uniform Memory Access System
다수의 CPU에 우선 접근이 가능한 메모리를 각각부여하여 하나의 쌍으로 만들어 준다.
CPU0이 memory0에 접근할 때는 로컬 버스를 이용한다. 버스의 간섭을 통해 우선 메모리 이외의 메모리에서도데이터를 주고받을 수 있다.
(이미지)
Clustered Systems
● Like multiprocessor systems, but multiple systems working together
- Usually sharing via a storage-area network(SAN)
- Provides a high-availability service which survives failures
- Asymmetric clustering has one machine in hot-standby mode
- Symmetric clustering has multiple nodes running applications, monitoring each other
- Some clusters are for High-performance computing(HPC)
- Applications must be written to use parallelization
- Some have distributed lock manager(DLM) to avoid conflicting operations ● 컴퓨터 하나가 하나의 CPU라고 생각하고 사용하는 것각각의 컴퓨터가 하나의 CPU인 것처럼 사용하는 것이다.
운영체제의 동작
● Bootstrap program : simple code to initialize the system, load the kernel, Bootloader 라고도 한다. ● Kernel loads: 커널 : 외부 시스템 혹은 하드웨어와 상관없는 소프트웨어적인 기능을 모아놓은 것 ● Starts system daemons(services provided outside of the kernel) ● Kernel interrupt driven (hardware and software)
- HW interrupt by one of the devices
- SW interrupt(exception or trap)
- SW error (e.g., division be zero)
- Request for operating system service :system call
- Other process problems include infinite loop, processes modifying each other or the operating system
- 전원이 들어오면 부트 프로그램이 가장 먼저 실행된다.
- 부트로터가 커널을 불러온다.
- 커널 밖에서 실행되는 system daemons을 실행한다.
- HW적, SW적인 인터럽트들이 반응한다(HW는 인터럽트, SW는 trap, exception)
multiprogramming(batch system) and timesharing(multitasking)
Multiprogramming and Multitasking ● Multiprogramming(Batch system) needed for efficiency
- single user cannot keep CPU and I/O devices busy at all times
- Multiprogramming organizes jobs(code and data) so CPU always has one to execute
- A subset of total jobs in system is kept in memory- One job selected and run via job scheduling
- When it has to wait (for I/O for example), OS switches to another job
- job : 코드와 데이터를 이루고 있는 실행 단위 ● Timesharing(multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running,creating interactive computing
- Response time should be < 1 second
- Each user has at least one program executing in memory -> process
- if several jobs ready to run at the same time -> CPU scheduling
- if processes don’t fit in memory, swapping moves them in and out to run-> Virtual memory allows execution of processes not completely in memory
- multiprogramming(batch system): 커널 내에 있는 job scheduling에 의해 job의 실행순서와 형태를 잘 조직하여 cpu가 하나의 job을 실행하게 함.
- timesharing(multitasking):job이 실행중일 때라도 어떤 근거에 기반하여 빠르고 자주 교체해서 실행한다.
공통점 : 둘 다 메모리에 프로그램이 상주함
차이점 : multiprogramming은 여러 개의 프로그램이 올라와 있어도 하나씩 실행
multitasking은 각 프로세스를 미세하게 나누고 동시에 실행(1-1, 2-1, 3-1, 4-1 실행 후 1-2, 2-2… )
메모리를 너무 많이 차지하면 외부로 내보내거나 가져오는 swapping이 발생
Dual-mode, Multimode operation
os는 user mode, kernel mode로 이루어짐
● Dual-mode operation allows OS to protect itself and other system components- User mode and kernel mode- kernel mode : 운영체제가 가진 모든 기능, 특히 운영체제가 해야 하는 주요한 기능, 서비스들 가운데 하나인 하드웨어 추상화를 통해 하드웨어 제어 기능 등을 제한 없이 사용, 특권을 가지고 있다고 표현한다. 몇몇 명령들은 특권 형태로만 실행되기도 한다.
- User mode : 시스템에 영향을 주지 않는 일반적인 실행모드
- Mode bit provided by HW
- Provides ability to distinguish when system is running user code or kernel code
- Some instructions designated as privileged, only executable in kernel mode
- System call changes mode to kernel, return from call resets it to user ● Increasingly CPUs support multi-mode operations- I.e. virtual machine manager(VMM) mode for guest VMs
Process Management
process는 thread로 이루어짐 (simple or multi thread), process들을 바꿀 떄 , 원래 하던일을 기억하는 것을 program counter라고 함
● A process is a program in execution. It is a unit of work within the system.Program is a passive entity, process is an active entity.
● Process needs resources to accomplish its task
- CPU, memory, I/O, files
- Initialization data ● Process termination requires reclaim of any reusable resources ● Single-threaded process has one program counter per thread ● Typically system has many processes, some user, some operating system running concurrently on one or more CPUs -> Concurrency by multiplexing the CPUs among the processes/threads
Processes Management Activities
The operating system is responsible for the following activities in connection with process management:
- Creating and deleting both user and system processes
- Suspending and resuming processes
- Providing mechanisms for process communication
- Providing mechanisms for deadlock handling
File-system Management
● OS provides uniform, logical view of information storage
- Abstracts physical properties to logical storage unit – file- Each medium is controlled by device(i.e., disk drive, tape drive)
- Varying properties include access speed, capacity, data transfer rate, access method(sequential or random) ● Files usually organized into directories ● Access control on most systems to determine who can access what ● OS activities include
- Creating and deleting files and directories
- Primitives to manipulate files and directories
- Mapping files onto secondary storage
- Backup files onto stable (non-volatile) storage media