link
6.004 So Far: Single-User Machines
- Hardware executes a single program
- This program has direct and complete access to all hardware resources in the machine
- The instruction set architecture (ISA) is the interface between software and hardware
- Most computer systems don’t work like this!
1️⃣ Minimal conceptual diagram (very clear)
+------------------------------------+
| Program |
| (Single binary, bare metal code) |
+------------------------------------+
|
| Instructions (ISA)
v
+------------------------------------+
| Instruction Set ISA |
| (RISC-V) |
+------------------------------------+
|
| Direct control
v
+------------------------------------+
| Hardware |
| CPU | Registers | RAM | I/O | MMU |
+------------------------------------+
2️⃣ Emphasizing “direct and complete access”
USER PROGRAM
(Only one program runs)
|
| load / store / jump
| arithmetic / control
v
============================
| RISC-V ISA |
============================
|
| 1:1 execution
| no mediation
v
+------------------------------------------------+
| HARDWARE |
| |
| +------+ +-----------+ +----------------+ |
| | CPU | | Registers | | Main Memory | |
| +------+ +-----------+ +----------------+ |
| |
| +----------------+ +--------------------+ |
| | I/O Devices | | Timers / Interrupt | |
| +----------------+ +--------------------+ |
| |
+------------------------------------------------+
3️⃣ Bare-metal execution (no OS layer)
┌───────────────────────────────────┐
│ Program │
│ main() │
│ ├─ arithmetic │
│ ├─ memory access │
│ └─ device control │
└───────────────────────────────────┘
│
▼
┌───────────────────────────────────┐
│ RISC-V ISA │
│ ADD, LW, SW, JAL, CSR, ECALL │
└───────────────────────────────────┘
│
▼
┌───────────────────────────────────┐
│ Hardware │
│ │
│ ALU → executes ADD │
│ Cache→ serves LW / SW │
│ MMIO → controls devices │
│ IRQ → raises interrupts │
│ │
└───────────────────────────────────┘Operating Systems
Multiple executing programs share the machine
Each executing program does not have direct accescc to hardware resources
Instead, an operating system(OS) controls these programs and how they share hardware resources
- Only the OS has unrestricted access to hardware
The application binary interface (ABI) is the interface between programs and the OS
운영 체제
여러 실행 중인 프로그램이 기계를 공유합니다
각 실행 중인 프로그램은 하드웨어 리소스에 직접 액세스할 수 없습니다
대신 운영 체제(OS)는 이러한 프로그램과 하드웨어 리소스 공유 방법을 제어합니다
- 오직 OS만이 하드웨어에 무제한으로 접근할 수 있습니다
애플리케이션 바이너리 인터페이스(ABI)는 프로그램과 운영 체제 간의 인터페이스입니다
+--------------------------------------------------+
| Programs |
| app1 app2 app3 |
| (compiled binaries) |
+--------------------------------------------------+
|
| ABI defines:
| - how functions are called
| - how syscalls work
v
+--------------------------------------------------+
| ABI |
| Syscall numbers | register usage | stack layout |
| ELF format | dynamic linking |
+--------------------------------------------------+
|
| kernel entry (ecall)
v
+--------------------------------------------------+
| Operating System |
| Process | Threads | Virtual Memory |
| Filesystems | Device Drivers |
+--------------------------------------------------+
|
| executes privileged ops
v
+--------------------------------------------------+
| RISC-V ISA |
| Instruction encoding |
| Privilege model (U/S/M) |
| Exception & interrupt semantics |
+--------------------------------------------------+
|
| electrical signals
v
+--------------------------------------------------+
| Hardware |
| ALU | Registers | DRAM | PCIe | Devices |
+--------------------------------------------------+
Nomenclature: Process vs . Program
A program is a collection of instructions
- (i.e., just the code)
A process is an instance of program that is beging executed
- Includes program code + other state ( registers, memory, and other resources)
The OS Kernel is a process with special privileges
Protection and privacy : Processes cannot access each other’s data
Abstraction : OS hides details of underlying hardware
- e.g., processes open and access files instead of issuing raw commands to the disk
Resouce management : OS controls how processes share hardware(CPU, memory, disk, etc.)
명명법: 프로세스 vs. 프로그램
프로그램은 지침 모음입니다
- (즉, 코드만)
프로세스는 실행 중인 프로그램의 한 예입니다
- 프로그램 코드 + 기타 상태(레지스터, 메모리 및 기타 리소스) 포함
OS 커널은 특별한 권한을 가진 프로세스입니다
보호 및 개인정보 보호: 프로세스가 서로의 데이터에 액세스할 수 없습니다
추상화 : OS는 기본 하드웨어의 세부 정보를 숨깁니다
- 예: 디스크에 원시 명령을 내리는 대신 파일을 열고 액세스하는 프로세스
리소스 관리: OS는 프로세스가 하드웨어(CPU, 메모리, 디스크 등)를 공유하는 방식을 제어합니다
+--------------------------------------------------+
| Process |
| ps1 ps2 ps3 |
| (compiled binaries) |
+--------------------------------------------------+
|
| ABI defines:
| - how functions are called
| - how syscalls work
v
+--------------------------------------------------+
| ABI |
| Syscall numbers | register usage | stack layout |
| ELF format | dynamic linking |
+--------------------------------------------------+
|
| kernel entry (ecall)
v
+--------------------------------------------------+
| Operating System |
| Process | Threads | Virtual Memory |
| Filesystems | Device Drivers |
+--------------------------------------------------+
|
| executes privileged ops
v
+--------------------------------------------------+
| RISC-V ISA |
| Instruction encoding |
| Privilege model (U/S/M) |
| Exception & interrupt semantics |
+--------------------------------------------------+
|
| electrical signals
v
+--------------------------------------------------+
| Hardware |
| ALU | Registers | DRAM | PCIe | Devices |
+--------------------------------------------------+
The OS kernel provides a private address space to each process
The OS kernel provides a private address space to each process
- Each process is allocated space in physical memory by the OS
- A process in not allowed to access the momory of other processes
OS 커널은 각 프로세스에 개인 주소 공간을 제공합니다
- 각 프로세스는 OS에 의해 물리적 메모리에 공간이 할당됩니다
- 다른 프로세스의 기억에 접근할 수 없는 프로세스
The OS kernel schedules processes into the CPU
- Each process is given a fraction of CPU time
- A process cannot use more CPU time than allowed
OS 커널은 프로세스를 CPU로 스케줄링합니다
- 각 프로세스에는 CPU 시간의 일부가 주어집니다
- 프로세스는 허용된 시간보다 더 많은 CPU 시간을 사용할 수 없습니다
The OS kernel lets processes invoke system services (e.g., access files or network sockets) via system calls
- OS 커널은 프로세스가 시스템 호출을 통해 시스템 서비스(예: 파일 또는 네트워크 소켓 액세스)를 호출할 수 있도록 합니다
============
Physical ┌────────────────────────────┐
│ OS Kernel memory │
Memory ├────────────────────────────┤
│ Process 1 memory │
├────────────────────────────┤
│ Free │
├────────────────────────────┤
│ Process 2 memory │
├────────────────────────────┤
│ Free │
├────────────────────────────┤
├ ... ┤CPU scheduling timeline (single core)_The OS kernel schedules processes into the CPU
CPU
│
│ RUNNING FREE PROCESS 1 FREE PROCESS 2 FREE
│ ───────────┬────┬───────────┬─────┬──────────┬─────┬────
│ ██████████ │ │ █████████ │ │ ████████ │
│ │ │ │ │ │
│ │ │ │ │ │
└─────────────────────────────────────────────────────────→ Time