# OS Chapter2
###### tags: `作業系統`
## *User Interface(UI)*
:::success
**CLI (command line interface)**
- command interpreter allows direct command entry
- implemented in kernel or by systems program
- 使用者透過**shell**下指令
:::
:::info
**GUI**
- 圖形介面
:::
## *System Calls*
:::success
- Programming interface to the services provided by the OS
- System calls are mostly accessed by programs via a high-level API rather than direct system call
- Comment API
- Win32 API for windows
- POSIX API for Linux
- Java API for JVM
:::
:::info
- API-System Call

※open() -> 呼叫trap
:::
:::warning
- System Call parameter passing
- pass in regeister
- sotred in a block , or table , in memory
- pushed onto the stack by the programm , popped off the stack by os
:::
## *System Services*
:::success
Most users' view of the operation system is defined by system programs , not system calls
:::
## *Linkers and Loaders*
:::success
- **Linker** : conbines object file into single binary executable file
- **Loader** :
- kernel的載入器
- bring binary executable file into memory to be executed
- Relocation : assigns final addresses to program and adjusts code and data in program to match addresses
- Dynamically Linked Libraries(DLLs) : are loaded when neede.

:::
## *Application Binary Interface(ABI)*
:::success
It defines how different components of binary code can interface for a given operating system on a given architecture.
:::
## *OS design and implementation*
:::success
Different design consideration
- User goal : OS should be convenient to use , easy to learn.
- System goal : OS should be easy to design , implement and maintain.
:::
:::info
Important principle
Policy : What will be done?
Mechanism : How to do it?
:::
## *OS structure*
:::success
- Monolithic structure - Unix
- a large number of functions for one level
- 缺點 : 功能越多,東西也越來越多
- Linux system structure
- modular design 模組化
- Layered approach
- OS is divided into a number of layers
- 缺點 : 但對於OS來說無法分得太清楚
- Microkernels
- 只留下基本、必要的
- communication takes place between user modules using message passing
- 缺點 : 變簡單了但效率變不好
:::
:::info
- Modules : many OS implement loadable kernel modules(LKMs) , 動態需要時才載入
- Hybird System : 混合型model
:::
:::warning
System Boot
:::