The operating-system interface
Introducido
5:52
Fundamentos de sistemas informáticos
This course follows a program from a single bit to a running process. The first two units are the alphabet: how bits encode data, and how logic gates compute…
Narración en inglés · subtítulos en inglés y 中文 que puedes cambiar
En esta lección
| English | Significado |
|---|---|
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| process/ˈprəʊses/ | proceso |
| thread/θred/ | hilo |
| file/faɪl/ | archivo |
| context switch/ˈkɒntekst swɪtʃ/ | cambio de contexto |
| virtual memory/ˈvɜːtʃuːəl ˈmeməri/ | memoria virtual |
| page table/peɪdʒ ˈteɪbl/ | tabla de páginas |
| TLB/ˌtiː el ˈbiː/ | TLB (caché de traducción de direcciones) |
| page fault/peɪdʒ fɒlt/ | falta de página |
| system call/ˈsɪstəm kɔːl/ | llamada al sistema |
Many programs, one machine
- A laptop runs a browser, music and an editor at once on a few processor cores. None of them can read another's memory, and none talks to the disk directly.
- The operating system 操作系统 makes this possible. It shares the machine safely, and programs use it through a small set of services.
Processes and threads
- A process 进程 is a program plus its execution state: its own address space, registers, PC and open files.
- A thread 线程 runs inside a process and shares that process's memory. Two processes do not share memory unless they ask to.
| Process | Thread | |
|---|---|---|
| Memory | its own address space | shared with its process |
| Registers and PC | its own | its own |
| Open files | its own | shared with its process |
Two threads of the same process share that process's memory.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Threads live inside one address space. Separate processes each get their own.
The context switch
- To share one core, the OS does a context switch 上下文切换: it saves the running process's registers and PC, switches the memory mapping, and loads the next process's state.
- The CPU caches are not saved. They are shared hardware, so after a switch they are simply cold for the new process.

A context switch does not save —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Caches are shared hardware and are just cold after a switch. The saved state is the registers, the PC and the mapping.
Virtual memory
- With virtual memory 虚拟内存, each process sees its own private addresses. Page tables 页表 map virtual pages to physical frames, and the TLB 快表 caches recent translations.
- It serves three needs: isolation (no process reads another's pages), the illusion of more memory than is installed, and fixed addresses for every program.
Virtual memory gives —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Three needs, one abstraction; page tables and the TLB do the mapping.
Page faults are normal
- A page fault 缺页 means the page is not in physical memory right now. The OS loads it from disk, updates the page table and runs the instruction again.
- This is demand paging, a normal part of operation. A crash comes from touching an address that is not mapped at all.
A page fault is usually —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
In demand paging the fault is the mechanism that brings data in.
Put the steps of a page fault in order.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
The program never notices, apart from the delay.
System calls
- A system call 系统调用 is how a program asks the kernel for help:
open,read,write,fork,execve. Each one traps into the kernel, runs with kernel privileges, then returns. - Files 文件 are named streams of bytes.
fd = open(path, O_RDONLY)thenread(fd, buf, 4096)reads the first 4 KiB, and Python'sopenwraps the same calls.
Match each system call to its job.
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Each call crosses into the kernel and comes back.
Worked example: translating an address
- Pages are 4096 bytes. Virtual address 9000: page $= \lfloor 9000 / 4096 \rfloor = 2$, offset $= 9000 - 8192 = 808$.
- The page table 页表 maps page 2 to frame 5, so the physical address is $5 \times 4096 + 808 = 21288$.
Pages are 4096 bytes. Which page number holds virtual address 13000?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
13000 ÷ 4096 = 3.17, so page 3 (it starts at 12288).
Pages are 4096 bytes and page 3 maps to frame 2. What physical address does virtual address 13000 become?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
Offset = 13000 − 12288 = 712. Physical = 2 × 4096 + 712 = 8904.
Three common slips
- Mixing up processes and threads. Processes 进程 have their own memory; threads share it.
- Thinking
malloctouches the disk. It hands out memory, not file space. - Reading every page fault as a crash. Most are the OS fetching a page, as designed.
Recap
- Process = program + state; a context switch 上下文切换 saves registers and PC and switches the mapping.
- Virtual memory: page tables and the TLB map virtual to physical, for isolation, illusion and convenience.
- A page fault is a fetch, not a failure; system calls are the doorway into the kernel.
¿Qué salió mal? Solo el equipo del sitio ve esta información.