Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Lecture #2 Operating Systems Overview 강의 내용 운영체제의 개요 운영체제의 발전 역사 1) 직렬 처리 시스템 2) 단순 일괄처리 시스템 3) 다중 프로그램 일괄처리 시스템 4) 시분할 시스템 현대 운영체제의 특징 시스템 호출 운영체제의 구조 Operating System 2 Operating System 응용 프로그램의 실행을 제어하는 프로그램 OS는 사용자의 요구에 맞추어 응용 프로그램의 실행과 종료를 제어한다 OS는 다수의 응용 프로그램 사이에 효율적인 자원 공유를 제어한다 사용자와 하드웨어 사이의 인터페이스 Operating System 응용 프로그램에 제공하는 기능에 대해 하드웨어의 상세한 제어 기능을 감추다 (Masking) 예: 하드디스크 입출력, 프린터 출력 등 OS가 하드웨어의 세부적인 제어를 수행하여야 한다 3 End User Programmer Application Programs Utilities OperatingSystem Designer Operating-System Computer Hardware 컴퓨터 시스템의 계층적 구조 Operating System 4 OS Services(1) 프로그램 개발 환경 제공 프로그램 실행 loading in memory, I/O and file initialization I/O 와 파일에 대한 접근 editors, compilers, linkers, and debuggers 외부 장치에 대한 입출력 및 파일 입출력 시스템 접근 시스템 자원 및 데이터에 대한 접근 보호 시스템 자원 접근 충돌 해결 Operating System 5 OS Services(2) 에러 검출 내부 및 외부 하드웨어 에러 에러 해결 간단한 에러 리포팅 오퍼레이션의 재시도 응용 프로그램 중단 소프트웨어 에러 memory error device failure arithmetic overflow access forbidden memory locations 운영체제 에러 Operating System 6 OS Services(3) 계정 관리 Operating System 시스템 자원 사용에 대한 통계 수집 시스템 성능 모니터링 (eg: response time) 시스템 튜닝 자료 수집 과금 자료 수집 (on multiuser systems) 7 운영체제의 발전 OS는 하드웨어의 기능향상 및 새로운 종류의 하드웨어을 적절히 이용하여야 한다 OS는 새로운 서비스를 제공하여야 한다 Character vs graphic terminals paging hardware 등 예: internet support 등 OS의 설계 및 구현 기술에 따른 변화의 필요성 Operating System modular construction with clean interfaces object oriented methodology 8 운영체제의 발전 역사 직렬 처리 시스템(Serial Processing) 단순 일괄처리 시스템(Simple Batch Processing) 다중 프로그램 일괄 처리 시스템 (Multiprogrammed Batch Processing) 시분할 시스템(Time-Sharing Systems) Modern Operating Systems: 병렬 시스템(Parallel Systems) : SMP 분산 시스템(Distributed Systems) 실시간 시스템(Real-Time Systems) 내장형 시스템(Embedded Systems) Operating System 9 직렬 처리 시스템(Serial Processing) 가장 초창기 컴퓨터 시스템 환경 (late 1940s~mid 1950s) 프로그래머가 직접 컴퓨터 하드웨어를 제어 운영체제가 없다 주요 문제점: Scheduling: 비효율적인 job scheduling Setup time: 하나의 job을 수행하기 위한 setup time이 상당히 길다 Operating System 10 단순 일괄 처리 시스템 (1) 최초의 운영 체제 (mid-1950s) 동작 방식: 1. 2. 3. 사용자는 카드 등으로 작성된 작업(job)을 컴퓨터 운영자에 제출한다 컴퓨터 운영자는 제출된 사용자 작업을 묶어 일괄작업(batch)을 컴퓨터에 입력한다 ‘모니터(Monitor)’ 프로그램이 일괄작업의 각 작업을 순서대로 실행한다 상주 모니터(Resident monitor)는 항상 실행되기 위해 주기억장치에 상주한다 모니터 유틸리티는 필요할 때에 주기억장치에 올라온다(loading) Operating System 11 단순 일괄 처리 시스템 (2) Early batch system Operating System bring cards to 1401 read cards to tape put tape on 7094 which does computing put tape on 1401 which prints output 12 Start Wait for Jobs Load New Job Execute Job Yes Next Job? No Simple Batch System Operation Operating System 13 모니터(Monitor) 14 모니터는 입력장치(카드판독기)에서 각 작업(사용자 프로그램)을 하나씩 읽어 들여 주기억장치에 저장한다(loading) 모니터 명령어에 의해 사용자 프로그램 실행이 시작된다 사용자 프로그램은 다음 상황 까지 실행된다: end-of-program 명령어 에러 발생 하나의 사용자 프로그램이 종료되면 다시 모니터가 실행된다. Operating System Job Control Language (JCL) (1) 모니터에게 작업 실행과 관련된 명령을 주기 위한 언어 what compiler to use what data to use 작업 포맷의 예: ----------------->> ‘$FTN’ 는 컴파일러을 불러 들여 프로그램 번역을 수행 하도록 한다 ‘$LOAD’는 번역된 객체 코드를 주기억장치에 올린다(loading) ‘$RUN’ 는 사용자 프로그램을 실행한다 Operating System $JOB $FTN ... FORTRAN program ... $LOAD $RUN ... Data ... $END 15 Job Control Language (JCL) (2) Structure of a typical FMS job – 2nd generation Operating System 16 일괄 처리 운영체제 CPU 및 다른 컴퓨터 자원의 유휴시간이 크다 사용자 프로그램이 입출력을 수행하는 경우에 CPU는 입출력 작업이 종료될 때까지 idle 상태에 있는다 사용자 프로그램과 모니터 프로그램을 교대로 실행한다 주기억장치 상의 여러 프로그램을 효율적인 교대 수행하기 위해서는 하드웨어 지원을 필요로 한다 Operating System 17 하드웨어 기능 향상(1) 메모리 보호 사용자 프로그램이 시스템 영역의 메모리에 접근할 수 없도록 메모리 보호 기능 지원 타이머 Operating System 하나의 작업이 시스템을 독점하는 것을 막는다 주어진 시간이 지나면 인터럽트를 발생한다 18 하드웨어 기능 향상(2) 특권 명령어 두개의 CPU 명령어 모드 지원 사용자 모드 모니터 모드(또는 슈퍼바이저(Supervisor) 모드) 모니터에 의해서만 수행되는 명령어 사용자 프로그램이 실행하면 인터럽트 발생 인터럽트 Operating System 사용자 프로그램과 모니터 사이의 제어권 전환을 융통성있게 할 수 있도록 지원 19 다중 프로그램 일괄처리 시스템(1) I/O 동작의 수행속도는 연산 명령어에 비하여 상당히 느리다 I/O 명령어를 가진 프로그램은 대부분의 시간을 입출력을 기다리는데 사용한다 따라서 주기억장치에 하나의 프로그램만 있는 경우(uniprogramming)에는 CPU의 효율성이 떨어진다 Operating System 20 다중 프로그램 일괄처리 시스템(2) 만약 주기억장치에 여러 개의 프로그램이 있는 경우, 하나의 프로그램이 입출력 작업을 기다리는 동안 CPU 는 다른 프로그램을 실행할 수 있다. multitasking (multiprogramming) Monitor 주기억장치 Program A Program B Program C Operating System 21 다중 프로그램 일괄처리 시스템(3) Operating System 22 단일 및 다중 프로그래밍 비교 (1) 예제: Operating System 23 단일 및 다중 프로그래밍 비교 (2) Operating System 24 단일 및 다중 프로그래밍 비교 (3) Operating System 25 다중 프로그래밍 요구 사항 Hardware support: I/O interrupts and (possibly) DMA Memory management Memory protection (data and programs) Software support from the OS: Scheduling (which program is to be run next) To manage resource contention Operating System 26 시분할 시스템(Time Sharing Systems)(1) 다중 프로그램 일괄처리 시스템은 사용자의 대화식 작업을 지원하지 않는다 긴 작업 반환 시간(Job Turnaround Time) 사용자의 반응 시간이 느리기 때문에 일반적으로 분당 2초 정도만이 실제 처리시간으로 이용한다 최적의 경우에 분당 30명의 사용자가 시스템을 공유할 수 있다 Operating System 27 시분할 시스템(Time Sharing Systems)(2) 시분할 시스템은 다수의 대화식 작업을 지원하기 위하여 다중 프로그래밍 방식을 확장한 시스템이다 다수의 사용자들이 프로세서 시간을 공유하도록 한다 Time Slice : 하나의 작업이 프로세서를 점유하는 시간 짧은 반응 시간(Respone Time) 다수의 사용자가 터미널에서 동시에 시스템을 사용할 수 있다(대화식 작업 수행) 파일 시스템 등이 보호되어야 한다 Operating System 28 시분할 시스템(Time Sharing Systems)(3) If Time Slice = 10 msec, Program A (30 msec) Program B (20 msec) Program C (10 msec) 주기억장치 Operating System Pgm A RUN RUN RUN Pgm B RUN RUN Pgm C RUN 10 ms 20 ms 30 ms 40 ms 50 ms 60 ms 29 Batch Multiprogramming vs. Time Sharing Early Example: CTSS Compatible Time-Sharing System (CTSS) Developed at MIT as project MAC Time Slicing: When control was passed to a user User program and data loaded Clock generates interrupts about every 0.2 sec At each interrupt OS gained control and could assign processor to another user CTSS Operation Problems and Issues 메모리 보호 파일시스템 보호 Multiple jobs in memory must be protected from each other’s data File system must be protected so that only authorised users can access 자원 사용 충돌 Contention for resources must be handled Printers, storage etc Modern Operating Systems의 특징(1) 최근에 운영체제에 새로운 기능요소가 지원 되고 있다 새로운 하드웨어의 발전 multiprocessor machines high-speed networks faster processors and larger memory 새로운 소프트웨어 필요성 multimedia applications Internet and Web access Client/Server applications Operating System 34 Modern Operating Systems의 특징(2) Microkernel Architecture Multithreading Symmetric Multiprocessing Distributed Systems Embedded Systems Object-Oriented Design Operating System 35 Microkernel architecture 커널에서 가장 필수적인 기능만을 지원 다른 OS 서비스는 사용자 모드 프로그램(servers) 으로 제공 primitive memory management (address space) Interprocess communication (IPC) basic scheduling device drivers, file system, virtual memory… More flexibility, extensibility, portability… 최근 운영체제는 microkernel 구조를 기반으로 하고 있다(예: Window-NT 등) Operating System 36 Multithreading 하나의 프로세스는 동시에 수행 가능한 thread 들의 집합이다 직렬적으로 수행할 필요가 없는 task로 이루어지는 응용 프로그램에 가장 유용하다 서버 프로그램: 웹서버 프로그램 등 하나의 프로세스를 구성하는 thread는 동일한 데이터와 자원을 공유한다 Operating System 37 Symmetric Multiprocessing (SMP) 다수의 프로세서를 가진 컴퓨터 각 프로세서는 동일한 기능을 가지며 주기억장치와 I/O 장치를 공유한다(symmetric) 운영체제는 프로세스/쓰레드를 프로세서간에 스케쥴링한다(real parallelism) Incremental growth just add another CPU! Robustness Operating System a single CPU failure does not halt the system, only the performance is reduced 38 Example of parallel execution on SMP Operating System 39 Distributed Systems 고유의 프로세서와 로컬 메모리를 가진 시스템이 다수 모여 구성된 컴퓨터 시스템 Loosely-coupled multiprocessor systems Clustered Systems 분산 운영체제의 특징: Operating System 자원 공유: 분산파일시스템 등 연산속도 향상: 부하분산(load balancing) 등 신뢰성(reliability): HA(High Availability) 등 40 Embedded Systems 작고, 전자 책과 메모 패드와 같은 적은 기능을 수행하는 작은 규모의 컴퓨터 PDA, 이동전화기, 가전장치 등의 장치에 내장되어 장치를 제어하는 컴퓨터 실시간 특성을 가짐 크기, 메모리 및 전원 등에서 제약 조건을 가짐 임베디드 운영체제 사례: Operating System RTOS(Real-time Operating System)- pSos etc Window-CE, Embedded Window-XP Embedded Linux 41 Object-Oriented Design 가장 최근에 이루어진 운영체제 기술 혁신 객체 지향 설계 원리는 핵심 기능을 가진 작은 커널을 모듈러하게 확장할 수 있도록 지원 프로그래머가 시스템의 무결성을 헤치지 않으면서 자신이 원하는 대로 운영체제를 구성할 수 있다 분산 도구 및 완전환 형태의 분산운영체제의 개발을 용이하게 한다 Operating System 42 시스템 호출 (1) 시스템 호출(System Calls) 사용자 프로그램과 운영체제 간의 인터페이스 시스템 호출 사용 예: 파일 복사 프로그램 Operating System 표준 라이브러리 함수를 통한 호출 어셈블리어 수준에서의 직접 호출 입력 파일 이름 및 출력 파일 이름에 대한 입출력 입력 파일 개방 / 출력 파일 생성 파일 읽기 / 파일 쓰기 파일 닫기 메시지 출력 프로그램 종료 43 시스템 호출 (2) 시스템 호출 사용자 프로그램 운영체제 프로그래머 관점 Operating System 44 시스템 호출 수행 과정 There are 11 steps in making the system call read (fd, buffer, nbytes) Operating System 45 시스템 호출 종류 (1) 프로세스 제어(Process Control) Operating System 프로세스 생성 및 종료 프로세스 적재 및 실행 프로세스 속성 설정 및 획득 등 46 시스템 호출 종류 (2) A stripped simple shell: while (TRUE) { type_prompt( ); read_command (command, parameters) if (fork() != 0) { /* Parent code */ waitpid( -1, &status, 0); } else { /* Child code */ execve (command, parameters, 0); } /* repeat forever */ /* display prompt */ /* input from terminal */ /* fork off child process */ /* wait for child to exit */ /* execute command */ } Operating System 47 시스템 호출 종류 (3) 파일 조작(File Management) 파일 생성 및 삭제 파일 개방 및 닫기 파일 쓰기 및 읽기 파일 속성 설정 및 획득 Operating System 48 시스템 호출 종류 (4) 디렉토리 조작(Directory Management) 디렉토리 생성 및 삭제 디렉토리 링크 파일시스템 Mounting Operating System 49 시스템 호출 종류 (5) 기타 시스템 호출 Operating System 장치 조작(Device Management) 장치 요구 및 해제 판독, 기록, 재배치 장치 속성 획득 및 설정 정보 유지 보수(Information Maintenance) 시간, 일자 정보 설정 시스템 자료 설정 등 통신(Communication) 통신 연결 생성 및 제거 자료 송수신 등 50 시스템 호출 종류 (6) Operating System 51 시스템 호출 종류 (7) Operating System Some Win32 API calls 52 운영체제 구조(1) 시스템 프로그램 사용자 관점의 운영체제 프로그램 개발과 실행 환경 제공 시스템 관리 기능 제공 파일 조작 기능 제공 시스템 호출에 대한 사용자 인터페이스 제공 Operating System 예: 컴파일러, 윈도우 탐색기, 제어판, 프린터 등 53 운영체제 구조(2) Operating System 54 UNIX OS 구조 Operating System 55 Modern UNIX Kernel Operating System 56 Modern UNIX Systems System V Release 4 (SVR4) Solaris 9 4.4BSD Linux Operating System 57 Windows Architecture Modular structure for flexibility Executes on a variety of hardware platforms Supports application written for other operating system Operating System 58 59 Operating System Operating System Organization Modified microkernel architecture Not a pure microkernel Many system functions outside of the microkernel run in kernel mode Any module can be removed, upgraded, or replaced without rewriting the entire system Operating System 60 Kernel-Mode Components Executive Contains base operating system services Memory management Process and thread management Security I/O Interprocess communication Kernel Operating System Consists of the most used components 61 Kernel-Mode Components Hardware abstraction layer (HAL) Device drivers Isolates the operating system from platform-specific hardware differences Translate user I/O function calls into specific hardware device I/O requests Windowing and graphics systems Operating System Implements the graphical user interface (GUI) 62 Windows Executive I/O manager Cache manager Object manager Plug and play manager Power manager Security reference monitor Virtual memory manager Process/thread manager Configuration manager Local procedure call (LPC) facility Operating System 63 User-Mode Processes Special system support processes Ex: logon process and the session manager Service processes Environment subsystems User applications Operating System 64 Client/Server Model Simplifies the Executive Improves reliability Possible to construct a variety of APIs Each service runs on a separate process with its own partition of memory Clients cannot not directly access hardware Provides a uniform means for applications to communicate via LPC Provides base for distributed computing Operating System 65 Threads and SMP Operating system routines can run on any available processor Different routines can execute simultaneously on different processors Multiple threads of execution within a single process may execute on different processors simultaneously Server processes may use multiple threads Share data and resources between process Operating System 66 Windows Objects Encapsulation Object class or instance Create specified instances of an object Inheritance Object consists of one or more data items and one or more procedures Support to some extent in the Executive Polymorphism Operating System 67