1. Operating System
Examples of OS
- UNIX: Free BSD, AIX, HP-UX, System V, Solaris
- LINUX: a variant of UNIX
- Windows 7, 10, 11, Windows Server 2019
- Android Marshmallow, Nought, 8, 9, ...
- macOS 11, 12, 13 / iOS 16 / ipadOS 15 ...
- ChromeOS
What is OS?
1. System SW
- Interface between HW and Apps(Users)
- manages HW and SW resources
- provides common services for computer programs

2. resource manager
- H/W(memory)
- S/W(stack, heap, page table)
- Files
- Folders
- Data
3. provides services for Apps&Users
OS Services
1. Program execution
- CPU scheduling, process state transition
- program이 virtual memory에 적재되는 순간(실행) process가 된다.
- execve(), fork(), wait(), exit(),...
2. Memory management
- Virtual memory와 physical memory를 mapping하는 것
- mmap(), mprotect(), madvise(),...
3. I/O operations
4. File system manipulation
- creat(), open(), read(), write(), unlink(),...
5. Communications including IPC(Inter-Process Communication)
IPC: 서로 독립적인 메모리 공간을 가진 여러 프로세스가 데이터를 주고받거나 통신하는 기법
- Shared memory, message passing
- Access to a shared resource allows computation speed-up, data availability. etc.
6. Error detection & handling
Multi-user OS
여러 사용자가 동시에 시스템에 접근하더라도 각 사용자는 독립적인 사용 공간을 할당받아 서로 간섭 없이 시스템을 사용할 수 있는 운영체제이다.

Some permit many concurrent users
- UNIX
- All Linux-based OS(Ubuntu)
- Mac OS X
- Windows Server 2022
- IBM AS400
- Banking system, Portal server, DB server
반대로, Single-user OS는 한 순간에 한 명의 사용자만 시스템을 사용할 수 있도록 설계된 운영체제이다. 대표적인 예로는 Windows가 있다.
Time Sharing OS
여러 process가 CPU를 사용할 때, CPU 시간을 아주 짧은 단위로 나누어 공유하는 기법 중 하나이다. 사용자는 이러한 시간 분할을 거의 인지하지 못할 정도로 매우 빠른 속도로 CPU 할당이 전환되어, 동시에 여러 작업을 수행하는 듯한 경험을 하게 된다. single core의 경우 token을 돌려서 사용한다.
Pros
- Each task gets an equal opportunity
- Less chances of duplication of software
- Can idle time can be reduced
Cons
- Reliability problem
- take care of security and integrity of user programs and data
- Data communication problem
Multi-user or Multi-tasking
- Multi-user와 Multi-tasking은 유사하다.
Processor는 HW를 의미하고, Process는 OS에서 관리하는 실행 단위를 뜻한다.
Functions of OS
OS Functions for ensuring efficient system operations
- Resource allocation
- Accounting
- keep track of and record which users use how much and what kinds of computer resources
- $top: 현재 시스템 자원 사용 현황 확인 명령어
- Protection
OS Components
- Process management
- Main memory management
- File management
- I/O system management
- Networking
- Protection & Security system
- Command interpreter system : shell, CLI, GUI
Sharing vs. Protection
Sharing
- Multi-user
- Multi-tasking
- Multi-processing
- Multi-threading
특정한 자원을 공유할 때, 안전한 공유를 위해서는 Protection이 중요하다.
Protection
- Separation
- Separate UIDs - Root, Normal users
- Home dir
- Process address space
- Virtual machines
- Separate email accounts on a web portal
서로의 영역을 침범하지 않도록 분리되어 있기 때문에, OS는 process 간 context switching을 수행한다.
Partition

물리적으로 완전히 구분
Virtual address space
Separation
- Processes in separate address spaces
- In a multi-user system, one user must not be allowed to write or read from another user's memory indiscriminately
- Code, Data, Heap, Lib, Stack
- User space vs Kernel space
각 프로세스는 32bits 기준으로 최대 4GB 크기의 고유한 virtual memory 공간을 할당받는다. 그렇다면 어떻개 수백 개의 프로세스가 동시에 실행될 수 있을까?
→ virtual memory
이는 각 프로세스의 virtual memory 중 실제로 활성화된 부분만 physical memory에 mapping되기 때문에 가능하다.
Virtualization
최하단에는 Infrastructure(Hardware)가 존재하고, 그 위에 운영체제가 설치된다. 운영체제 위에 Hypervisor(VM ware, virtual box)를 설치하면, 내부에 또 다른 운영체제인 Guest OS를 실행할 수 있다.
- Type1: Type2보다는 빠르지만, VM 자체가 번거롭다.
- Type2: general VM
- Layer가 깊기 때문에 HW까지 접근하려면 오랜 시간 소요
- Type3: Container
- Guest OS가 없기 때문에 speed가 매우 빠르지만, separation이 약해 공격에 취약하다.