채록채록
[OS] Concepts, User Interface services, System programs, Linker, Loader, Dual mode 본문
Developing
[OS] Concepts, User Interface services, System programs, Linker, Loader, Dual mode
김책은 2025. 7. 25. 07:44
abstract concepts
hardware 위에 operating system, 그 위에 user and other system programs
- os 안에 user interfaces : gui, batch, cli
- system calls : os위에서 동작하는 appliation이 hardware 자원을 쓸 수 있도록(=사용자의 요청을 수행할 수 있도록) 해주는 무언가를 interface로 만든 것
- os의 핵심 기능 kernel(service) : program execution(loader), i/o operations, file systems, communication, resource allocation, accounting, error detection, protection and security 등
user interface services
- command line interpretier(cli) 를 제공하는 system에서의 해석기 = shell, gui, touch screen interface 등
system programs
- kernel&user programs 사이 무언가
- system call의 program
- program development&execution을 위한 환경을 제공
- os의 핵심 기능을 제어
- compiler를 필요로 한다.
Linker and loaders
code 덩어리인 source program → compiler(preprocessor&translator)가 처리 → object file로 묶음
→ linker가 other object files도 이용하면서 → 하나의 실행파일로 만든다
→ loader가 memory에 올려서 process로 만들어주고 → memory에서 프로그램이 실행된다
→ 프로그램 실행 중 필요하다면 공유 라이브러리로 jump하기도 한다.
- Static Linking
- 라이브러리 내 필요한 binary code를 밑에다 붙인다.
- Dynamic Linking
- 프로그램 실행 중 공유 라이브러리로 jump
Dual Mode operation
- protection : 바로 process가 cpu 위에서 동작하지 않는다 abstraction : system call을 직접 코드에서 사용하는 경우는 드물다. os에 코드가 구현되어있다.
- user mode & kernel mode
user process의 i/o 요청(system call 형태) → trap to kernel mode → kernel이 cpu 점유해서 find handler in vector table(코드는 os에 구현) → i/o device가 역할 수행하는동안 process는 waiting 상태 → another process run → i/o 완료 → interrupt → interrupt handler → ready queue
- 자주 쓰이는 명령들은 벡터값으로 mapping 시켜놓는다.
- os 한다리 건너는 kernel overhead 줄이기 위해
- response time 줄이기 위해
- function code의 시작 주소와 연결되어 있다.
- system call, interrupt handler… etc
- 라이브러리 함수(ex : 표준 C 라이브러리의 system call 함수)를 통해 system call 호출
- 라이브러리 함수는 내부적으로 해당 system call 번호를 사용하여 적절한 핸들러 함수를 호출
- Parameter passing
- user program에서 system call 함수 호출할 때
- 무조건 register 통해서 system call input parameter(argument) 전달
- os에 구현되어있는 system call 번호에 대한 code에서 그 parameter 사용
- system call service in unix(posix) & windows
- posix에는 있는데 windows에는 없는 것도 많다..
kernel의 종류
- Monolithic kernel
- 모든 기능을 한 덩어리로
- System call - integrated Kernel - Hardware
- by Function calls
- Micro kernel
- 꼭 가져야하는 기능은 kernel이 제공
- 그 외의 기능들은 service 형태로 multiple servers가 제공
- System call - multiple servers - Microkernel - Hardware
- by Massage passing
OS structure
- Simple structure
- batch system : single process system
- MS-DOS
- Monolithinc structure
- user programs - OS kernel(모든 기능 : file system, vm, i/o driveres, process control, system services, swapping, networks, protection, interrupt handling, windows, accounting…) - hardware
- 장점 : 모두 kernel mode에서 동작하기 때문에 system call단에서 한방에 처리가 가능하다.
- memory management, file system, process management 등의 기능이 동일한 주소 영역에 구현되어 있기 때문
- 단점 : 소프트웨어 엔지니어링 이슈 (유지보수 이슈), 서로 dependency가 높아진다, 하드웨어의 제약이 존재한다.
- Layered approach
- os가 독립적으로 모듈화 되어있는 계층들로 분리된다.
- 장점 : 새로운 기능을 추가/수정할 때 각각의 계층만 수정하면 된다, 유지보수 측면에서 유용
- 단점 : 각 계층을 나누는 기준이 모호하다, 현실성이 없다.
- Microkernel structure
- user mode - kernel mode - hardware
- 핵심적인 기능(Interprocess Communication, memory management, cpu scheduling) 은 microkernel에, in kernel mode
- 그 외 부수적 기능(application program , file system, device driver)은 user mode에 사용자 프로그램으로 구
- application add on으로 kernel에 올라가지 않는다.
- hardware control은 당연히 kernel에 trap을 걸고 부탁을 해야하지만 논리적 부분만 구현했다는 뜻
- 다른 application보다 권한이 더 높아 cpu scheduler에 의해 먼저 수행된다.
- 단점 : mode switch가 필요한 구조이므로 (trap → trap handeling → i/o) 오버헤드 발생
- Moduler approach
- 각각 의존성이 없는 것들을 Loadable Kernel Module로 개발
- 몇개씩 묶어서 compile하여 kernel을 만든다.
- 장점 : image가 작기 때문에 부팅시 memory 부담이 적다.
- Hybrid approach
- gui - application environments and services - kernel environment - hardware
- 하나의 시스템에서 두개의 os가 실행된다
- 한 os가 시스템을 부팅하고 다른 os는 시스템의 나머지 리소스 사용
- ex : iOS
- Cocoa Touch - Media Services - Core Services - Core OS