공부/CS

02. 운영체제의 개념과 구조

보리콩 2021. 8. 14. 18:56

Chapter 1-2.

Introduction & O/S Structures

 

1.1 What Operating Systems Do

An operating system is a software that manages a computer's hardware.

It also provides a basis for application programs and

    - acts as an intermediary between

    - the computer user and the computer hardware.

 

A computer system can be divided roughly into four components:

    - the hardware,

    - the operating system,

    - the application programs,

    - and a user

 

컴퓨터 하드웨어위에 OS라는 추상적인 레이어가 있다. 시스템과 application programs이 OS와 통신을 하면 하드웨어에 트랜스페어런트하게? 프로그래밍 할 수 있다.

 

Defining Operatiom Systems

There are NO universally accepted definition of an operating system.

A more common definition is that

    - "the one program running at all times on the computer"

    - usually called the kernel.

Along with the kernel, there are two other typpes of programs:

    - system programs

    - application programs

커널을 통해 system programs과 application programs의 인터페이스를 제공해준다.

 

 

1.2 Computer-System Organization

A modern computer system consist of:

    - one or more CPUs and

    - a number of device controllers connected through a common bus.

현대에 와서는 기존의 modern computer system을 classical computer system(전통적인 컴퓨터)이라고 부른다.

현대의 modern computer system은 신경망, 네트워크, 양자컴퓨터와 같은 폰노이만 아키텍쳐를 따르지 않는 컴퓨터를 말한다.

 

A bootstrap program is

    - the first program to run on computer power-on, 

    - and then loads the operating system.

부트스트랩은 부츠에 달린 고리 신발을 신을 때 잡고 당기는 역할

파워를 키면 컴퓨터가 켜지고 cpu가 메모리에서 제일 먼저 EEP ROM(? 뭔지 모르겠다)를 가져오는데 이걸 bootstrap이라 한다.

부팅용 프로그램. os를 메모리에 로딩하는 역할

 

Interrupts

Hardware may trigger an interrupt at any time 

by sending a signal to the CPU, usually by way of the system bus. 

하드웨어가 언제든 interrupt을 트리거할 수 있고 시그널을 시스템 버스를 통해서 CPU에 보내준다.

I/O디바이스의 입력을 CPU에 알려줄 때 Interrupts라는 방법으로 알려주게 된다. CPU와 I/O 디바이스의 통신 방법 중 하나.

 

von Neumann architecture (폰 노이만 아키텍쳐)

• A typical instruction-execution cycle 컴퓨터에 내릴 수 있는 명령어 집합(instruction set)

    - first fetches an instruction from memory ->fetch-execute 사이클을 폰노이만 아키텍쳐라 한다.

    - and stores that instruction in the instruction register. 메모리에서 명령어 레지스터

• The instruction is then decoded

    - and may cause operands to be fetched from memory

    - and stored in some internal register.

• After the instruction on the operands

    - has been executed,

    - the result may be stored back in memory.

 

The wide variety of storage systems can be organized in a hierarchy according to:

    • storage capacity,

    • and access time

RAM은 휘발성 메모리 -> 데이터를 저장할 곳이 필요. storage system

storage system은 계층 구조로 이루어져 있다. (용량, access time(접근속도)에 따라서)

register -> cache(램보다 빠름 비싸서 용략은 작음) -> main memory -> solid-state disk(ssd)메모리 형태의 하드디스크 -> hard disk(HDD)-> optical disk -> magnetic tapes (데이터 백업)

 

I/O Structure

• A large portion of OS code is dedicated to managing I/O

DMA(Directed Memory Access) CPU가 별로 할 일 이 없을 땐 네트워크와 디바이스가 바로 연결

 

 

1.3 Computer System Architecture

▪ Definitions of Computer System Components

    - CPU - The hardware that executes instructions.

    - Processor - A physical chip that contains one or more CPUs.

    - Core - The back computation unit of the CPU.

    - Multicore - Including multiple computing cores on the same CPU.

    - Multiprocessor - Including multiple processors.

 

Symmetric multiprocessing (SMP)

• The most common multiprocessor systems,

    - in which each peer CPU processor performs all tasks.

• Asymmetric multiprocessing: ->  대부분 symmetric하다.

    - each processor is assigned a specific task.

 

Multi-core design

    • with several cores on the same processor chip.

CPU를 여러개 다는 것은 비싸니까 CPU안에 따로 CPU core(registers와 cache를 가지고 있는?) 회로를 구성할 수 있다. 

코어의 개수에 따라 듀얼 코어 쿼드코어 등등으로 부른다.

 

 

1.4 Operating System Operations

Multiprogramming

    • runs more than one program at a time.

    • keeps several processes in memory simultaneously. 메모리에 프로세스가 동시에 올라가 있으면 

    • to increase CPU utilization. 씨피유 사용 효율을 높일 수 있다.

예전에는 프로그램을 한 개만 로딩해서 처리했다.

이제는 메모리에 여러 개의 프로그램을 동시에 올려놓고 처리한다.  

 

 

Multitasking (=multiprocessing)

• a logical extension of multiprogramming. 

    - in which CPU switches jobs so frequently that 

    - users can interact with each job while it is running.

CPU scheduling:

    - If several processes are ready to run at the same time,

    - the system must choose which process will run next

 

시간을 쪼개 쓰자 -> time sharing 시분할

CPU의 입장에서는 사용자의 입력처리를 굉장히 빠르게 할 수 있기 때문에 대부분 놀고있게 된다.

이때 여러가지 일들을 쪼개서 switch하며 처리한다면 사용자 입장에서는 CPU가 여러 일을 동시에 처리하는 것처럼 느끼게 된다. concurrency, palleleism?

 

그런걸 하려면 cpu scheduling필요

목표는 CPU 효율을 높이는 방법을 선택하는 것

 

Two separate mode of operations:

user mode and kernel mode 유저모드와 커널 모드

• to ensure that an incorrect program 엉뚱한 작업을 하면 막아주는 것도 운영체제가 해야한다.

    - cannot cause other programs to execute incorrectly

커널작업이 아니면 하드웨어 제어를 직접적으로 하지 못하게 만듬

    -> os를 제외하고도 유저프로세스는 직접적으로 하드웨어를 제어하지 못하기 때문에 나쁜짓을 하기가 힘들어진다.

 

 

1.7 Virtualization

현대적 컴퓨터의 시스템

Virtualization is (가상화 기술)

• a technology that allow us

    - to abstract the hardware of a single computer

    - into several different execution environments.

• VMM: Virtual Machine Manager

    - VMware, XEN, WSL, and so on.

하드웨어 안에서 운영체계를 여러개 돌릴 수 있지 않을까? -> VMM

하드웨어 위에 VMM을 올려서 이 위에 여러 os를 올리는 것

 

 

1.10 Computing Environments

Operating Systems in the Variety of Computing Environments 컴퓨팅 환경이 너무 복잡해졌다.

    • Traditional Computing

    • Mobile Computing

    • Client-Server Computing

    • Peer-to-Peer Computing -> ptp컴퓨팅(N:N시스템): 음악, 영화파일 공유 -> BitTorrent? -> BitCoin(Block Chain)

    • Cloud Computing -> AWS, Azure, GCP, 네이버 클라우드...

    • Real-Time Embedded Systems -> RTOS 하드웨어를 리얼타임으로 제어

 

 

2.1 Operating System Services

OS provides an environment for the execution of programs. 프로그램이 실행될 수 있는 환경을 제공해 주는 것이 OS

    • User interface

    • Program execution

    • I/O operation

    • File-system manipulation

    • Communications

    • Error detection

    • Resource allocation

    • Logging

    • Protection and security

process-thread 개념이 가장 중요하다. 

multiprocessing을 하다보면 동기화(synchronixation)문제가 생긴다.

제대로 해결하지 못하면 deadlock이 생긴다.

메모리 메니지먼트..

 

 

2.2 User and Operating-System Interface

Three fundamental ways for users to interface with the OS: 사용자가  OS에 인터페이스하기 위한 방법

• CLI: command line interface, or command interpreter

    - known as shells: sh, bash, csh, tcsh, zsh, etc.

• GUI: graphical user interface

    - Windows, Aqua for MacOS, KDE/GNOME for Linux, etc.

• Touch-Screen Interface

    - Android UI, iPhone UI, etc.

 

 

2.3 System Calls

컴퓨터 응용프로그램은 os와 어떻게 인터페이스 하느냐 -> system call

System calls 

    • provide an interface to the services made available by the OS.

    • API: Application Programming Interface 

os의 api가 system call

 

우리가 항상 명령어들을 일일이 쳐서 call을 하기는 너무 귀찮으니까 라이브러리를 만듬

Examples of Windows and UNIX system calls:

process Control: fork( ), wait( ) => 이 강의에서는 이정도만 다룰 것

 

The standard C library

• provides a portion of the system-call interface

 

 

 

 

 

 

출처: 운영체제 공룡책 강의 [02. 운영체제의 개념과 구조]