OS services
운영체제는 이런 서비스를 제공해야 하는지 생각하며 개발자 관점에서 공부하기
프로그래머의 편리성을 위해 제공되는 서비스
- user interface : user, program에게 실행과정, 걀과를 알려주어야 함. ex)LI, 6UI, Touch0screen, batch
- program excation(프로그램 실행)
- I/o operation(입출력 수행)
- file system manipulation(파일시스템 조작)
- communications(통신)
- error detections(오류 검출)
시스템의 효율적 운영을 위해 제공되는 서비스
- resource allocation(자원 할당)
- logging(회계)
- protection and security(보호)
Interface-CLI
ex) command 창, DOS prompt 창 CLI or command line interpreter allows direct command entry
- Sometimes implemented in kernel.
- Sometimes by systems program(하나의 특수한 프로그램처럼)
- Sometimes multiple flavors implemented – shells, bourne shell, C shell, Korn shell
shell : 내부에 있는 커널을 밖으로 꺼내 사용할 수 있도록 해준다.
shell script : 각 shell은 고유한 스크립트 명령을 가지고 있다. 작은 프로그램 형태를갖고 있기도 한다.
Interface-GUI
직관적이고, 퍈리함 User-friendly desktop interface
- Usually mouse, keyboard, and monitor
- Icons represent files, programs, actions, etc
- Various mouse buttons over objects in the interface cause various actions :(provide information, options, execute function, open directory known as a folder)
- Invented at Xerox PARC(-> Mac, Windows, Xwindows, Gnome)
Many systems now include both CLI and GUI interfaces - Microsoft Windows is GUI with CLI “command“ shell
- Apple Mac OS X is “Aqua“ GUI interface with UNIX kernel underneath and shells available
- Unix and Linux have CLI with optional GUI interfaces(CDE, KDE, CNOME)
Touchscreen Interfaces
Touchscreen devices require new interface
- Mouse not possible or nor desired
- Actions and selection based on gestures
- Virtual keyboard for text entry
Computer-System Operation (I/O)
- I/O devices and the CPU can execute concurrently.(버스 사용을 두고 경쟁관계)
- Each device controller is in charge of a particular device type.
- Each device controller has a local buffer.
- CPU moves data from/to main memory to/from local buffers
- Device controller informs CPU that it has finished its operation by causingan Interrupt.
Common Functions of Interrupt
Common Functions of Interrupt
- Interrupt transfers control to the interrupt service routine generally,through the interrupt vector, which contains the addresses of all the service routines.
- Interrupt architecture must save the address of the interrupted instruction.실제로는 주소 뿐 아니라 데이터 등 모든 상황을 저장하고 있어야한다.(stack)
- 일반적으로 인터럽트가 처리되는 동안 다른 인터럽트는 들어오지 않는다.그러나 처리되게 하는 시스템도 있을 수 있다(우선순위로 구분).인터럽트 실행 중 새로 들어온 인터럽트는 대기 상태로 있다.(pending)
- 내부 소프트웨어에 의해 인위적으로 만들어진 interrupt를 trap이라고 한다.(divide by zero …)
- 대부분의 OS는 Interrupt driven(인터럽트 구동방식)으로 동작, 모두 그런 것은 아니다.
- Interrupt : 하드웨어적인 사건(clock, 디스크 쓰기 완료, 패킷 도착)
- Trap : 소프트웨어적인 사건(페이지 부재 결함, divide by zero, 시스템 호출, accessviolation)
- 사용자가 운영체제 내부로 서비스를 받기 위해(시스템 콜) 안으로 들어가는 절차
- 사용자 프로그램이 하기 어려운 일을 운영체제에게 부탁하기 위해 시스템 콜을 호출한다.
interrupt & trap
- interrupt : 하드웨어 적인 사건
- trap : 소프트웨어적인 사건
Direct Memory Access Structure (DMA structure)
- Too much data transfer via CPU
- DMA 제어기는 메모리의 속도와 비슷한 속도로 정보를 전송할 수 있는 고속의 입출력장치를 위해 사용된다.
- 장치 제어기는 전체 자료블록을 CPU의 간섭 없이 직접 기억장치에서 버퍼 저장 장치로 블록 단위로 전송한다.
- byte(or word) 당 하나의 인터럽트를 발생시키는 것이 아니라 블록 단위로 인터럽트를발생시킨다. (word mode일 때는 cycle stealing이 일어난다)
Cycle Stealing
- DMA 전송시간 중에 CPU와 Memory는 데이터를 상호 전송할 수 없다. -> I/O가 버스를 사용하고, CPU의 버스는 hold상태에 있게 된다.
- 이 경우, CPU가 처리할 명령어 및 처리할 데이터가 메모리에 있으므로,CPU 원래의 목적(입출력 데이터 전송에 관계없이 CPU가 계속 동작)에 문제가 있게 된다.=> CPU 동작 시 메모리와 관계없는 사이클에만 DMA의 수행을 하게 되는데, 이를 Cycle Stealing이라고 한다. (CPU의 Cycle을 도용한다고 하여)
storage structure
- 메인메모리 : 빠르게 읽고 쓸 수 있는 것 중 저렴한 것 사용, byte단위로 데이터에 바로 접근할 수 있어야 함. 현재 유일한 장치는 RAM, 프로그램과 데이터를 모두 저장하기엔 용량이 매우 부족, 휘발성
- 보조기억장치 : 주 기억장치에 저장하지 못하는 것들을 저장, 속도는 떨어지지만 휘발성이 약하고 용량이 큼,
클러스터
- 여러 개의 섹터를 묶어서 읽는 데이터 기본 단위. SW적으로 접근 할 때 , 섹터의 크기가 너무 작기 때문에 클러스터로 묶어준다. (처음 포맷 시 섹터를 몇개 만들건지 설정할 수 있음)
RAID
여러대의 물리적 디스크를 하나의 논리적 디스크로 인식시키는 기술
성능을 향상시키거나, 안정성을 향상시키는 목적으로 사용
각각의 목적에 따라 여러가지의 결합 방법으로 구성시킬 수 있다.
Storage Hierarchy
Storage systems organized in hierarchy
- Speed
- Cost
- Volatility
시스템 콜
운영체제가 제공하는 서비스 프로그램의 인터페이스
- 일반적으로 C나 C++같은 고급언어로 작성된다. : 어셈블리어로도 만들어 질 수 있다.
- 고급언어에서는 시스템 콜은 불편하거나 힘들 수도 있다. 이를 위해 고급언어로 함수를 사용할 수 있도록 만든 것이 API이다.
시스템 콜 파라미터 패싱 시스템 콜도 하나의 함수처럼 동작하므로 전달인자가 있을 수 있다. cpu안의 register를 직접 이용하는 방식으로 데이터를 넣어 사용한다. 임의의 메모리에 테이블 같은 형태로 데이터를 저장하고 그 위치를 전달한다. 스택에 데이터를 넣은 후 몇개의 데이터가 저장됐는지 알려주면 마지막부터 데이터를 가져간다. 가장 간단한 방법은 레지스터에 직접 저장하는 것이다.
##Type of System Calls 아래의 6가지 범주로 대략 묶을 수 있다. ● Process control
- Process : 저장돼 있는 상태의 프로그램이 메인 메모리에 올라와서 실행될 수 있는 상태
- 프로그램을 프로세스로 Load하고, 실행하는 등의 system call
- Dump memory if error
- Debugger for determining bugs, single step execution
● File manipulation
- 파일을 만들고, 복사하고 등의 일을 처리
● Device management
- 주변 장치의 핸들링 - 운영체제를 만드는 회사에서 발표한 표준에 맞추어 하드웨어를 만든다.
● Information maintenance
- 시간과 날짜 등 정보를 다루는 system call
● Communication
- 프로세스 간의 통신, 이때 각 프로세스는 서로 다른 컴퓨터에 있을 수 있다.
● Protection
- 하드웨어 혹은 리소스 보호
- 운영체제가 하는 가장 중요한 일 중 하나
##System Service ● 시스템 서비스는 프로그램 형태로 대부분 제공(시스템 프로그램) ● System programs provide a convenient environment for program developmentand execution. They can be divided into :- File manipulation- Status information sometimes stored in a File modification- Programming language support- Program loading and execution- Communications- Background service- Application programs ● 운영체제에 부속되는 프로그램 ● Most users’ view of the operation system is defined by system programs,not the actual system calls ● 중요한 system call을 이용한 간단한 유틸리티들의 집합
Simple Structure
● Monolithic Structure ● i.e. MS-DOS – written to provide the mostfunctionality in the least space
- Not divided into modules
- Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated ● 최소의 공간에 최소의 방법으로 최대의 기능을 넣기 위해심플하게 만들었다. ● 어플리케이션이 바로 하드웨어를 쓸 수 있다. (하드웨어에서 시스템 콜 제공)