分页(paging)与分段(segmentation)在内存管理上有什么不同?
How do paging and segmentation differ in memory management?
分页把物理和虚拟内存都切成固定大小的页与页框,消除了外部碎片、便于按需调页,但页内仍有内部碎片。分段按逻辑意义(代码、堆、栈)划分为大小可变的段,便于保护与共享,却容易产生外部碎片。x86 硬件同时提供两套机制,但现代操作系统普遍采用平坦段模型、实际依靠分页完成内存管理与保护——在 x86-64 长模式下分段已基本被禁用。
Paging divides both physical and virtual memory into fixed-size pages and frames, eliminating external fragmentation and enabling demand paging, though internal fragmentation remains within a page. Segmentation splits memory into variable-size logical segments (code, heap, stack) that ease protection and sharing but suffer external fragmentation. x86 hardware provides both mechanisms, yet modern operating systems use a flat segment model and rely on paging for memory management and protection—segmentation is largely disabled in x86-64 long mode.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Tanenbaum《现代操作系统》;Silberschatz 等《操作系统概念》
Tanenbaum, Modern Operating Systems; Silberschatz et al., Operating System Concepts
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#分页 #分段 #内存管理 #虚拟内存
什么是 inode,它存储了文件的哪些信息?
What is an inode and what information does it store about a file?
在类 Unix 文件系统中,inode 是描述一个文件(或目录)的元数据结构,存放权限、所有者、大小、时间戳以及指向数据块的指针。文件名保存在目录项里,与 inode 编号相关联,因此一个文件可有多个名字(硬链接)。删除文件实际是减少其链接计数,计数为零才真正释放空间。
In Unix-like file systems, an inode is the metadata structure describing a file or directory, holding permissions, owner, size, timestamps, and pointers to data blocks. The file name lives in a directory entry linked to the inode number, so a file can have several names (hard links). Deleting a file really just decrements its link count, and the space is freed only when that count reaches zero.
难度 专业 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#inode #文件系统 #元数据
什么是优先级反转,1997 年火星探路者号为什么反复自动重启?
What is priority inversion, and why did the 1997 Mars Pathfinder keep resetting itself?
优先级反转指低优先级任务持有一把互斥锁,高优先级任务必须等这把锁;若中等优先级任务不断抢占低优先级任务,高优先级任务就被第三方间接无限期阻塞。探路者号上,高优先级的总线管理任务等待低优先级气象任务持有的共享数据锁,中优先级通信任务频繁运行使气象任务迟迟无法释放锁,看门狗判定总线任务超时便触发整机复位。JPL 远程上传补丁打开 VxWorks 互斥量的优先级继承选项,让持锁者临时升到等待者的优先级,问题即消除。
Priority inversion occurs when a low-priority thread holds a mutex that a high-priority thread needs while a medium-priority thread keeps preempting the lock holder, so the high-priority thread is blocked indefinitely through a third party. On Pathfinder a high-priority bus management task waited on data shared with a low-priority meteorological task, medium-priority communications work starved the lock holder, and the watchdog saw the bus task miss its deadline and reset the spacecraft. Engineers at JPL uploaded a patch enabling VxWorks priority inheritance, which temporarily raises a lock holder to the waiter's priority and ended the resets.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-11-03
来源 · Source
Glenn Reeves(JPL)《What Really Happened on Mars Rover Pathfinder》(1997);Sha、Rajkumar 与 Lehoczky《Priority Inheritance Protocols》(IEEE Transactions on Computers, 1990)
Glenn Reeves (JPL), "What Really Happened on Mars Rover Pathfinder" (1997); Sha, Rajkumar & Lehoczky, "Priority Inheritance Protocols," IEEE Transactions on Computers (1990)
独立核验依据 · Independent verification: 核验依据 1 CROSSREF 标识 10.1109/12.57058:Priority inheritance protoc
#优先级反转 #优先级继承 #实时系统 #火星探路者
Unix 文件系统里的 inode 记录的是什么,为什么它和文件名分离?
What does an inode record in a Unix file system, and why is it separate from the file name?
inode 保存文件的元数据与数据块指针(权限、大小、时间戳、磁盘位置),而文件名只存在于目录项里并指向 inode 编号。这样同一文件可有多个名字(硬链接),删除名字也不会立刻销毁数据。
An inode holds a file's metadata and data-block pointers—permissions, size, timestamps, disk location—while the name lives only in a directory entry pointing to the inode number. This lets one file have many names (hard links) and deletion not instantly destroy data.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-11-03
来源 · Source
McKusick 等《伯克利快速文件系统》(ACM TOCS, 1984);Tanenbaum《现代操作系统》
McKusick et al., 'A Fast File System for UNIX' (ACM TOCS, 1984); Tanenbaum, 'Modern Operating Systems'
独立核验依据 · Independent verification: 核验依据 1 ISBN 9787111573692(豆瓣书目条目: 现代操作系统);本条出处含多部著作,此标识只担保上面点名的
#inode #文件系统 #硬链接 #元数据
死锁是怎么产生的,Dijkstra 的银行家算法如何避免它?
How does deadlock arise, and how does Dijkstra's banker's algorithm avoid it?
当多个进程各自占有部分资源又互相等待对方手里的资源,且形成循环等待时就会死锁。银行家算法在每次分配前模拟『若借出是否仍能保证所有人最终完成』,只在安全时才批准,从而预防死锁。
Deadlock occurs when processes each hold some resources and circularly wait for others'—a cycle of hold-and-wait. The banker's algorithm simulates before each grant whether everyone could still finish; it approves only if a safe state remains, preventing deadlock.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Dijkstra《银行家算法》(1965);Coffman 等《死锁的系统特征》(1971);Silberschatz《操作系统概念》
Dijkstra, 'The banker's algorithm' (1965); Coffman et al., 'System deadlocks' (1971); Silberschatz, 'Operating System Concepts'
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#死锁 #银行家算法 #循环等待 #安全状态
什么是系统颠簸(Thrashing)?
What is thrashing in an operating system?
颠簸指系统因物理内存不足而频繁进行页面换入换出,CPU 大量时间花在等待磁盘上,几乎无法执行有效任务。通常由多道程序度过高、页面置换算法不当引起,可通过工作集模型来缓解。
Thrashing happens when a system, short on physical memory, constantly swaps pages in and out, so the CPU spends most time waiting on disk and little on useful work. It is usually caused by too high a degree of multiprogramming or poor page replacement, and can be mitigated with the working-set model.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
《操作系统概念》(Abraham Silberschatz 等)
Operating System Concepts (Silberschatz et al.)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#颠簸 #页面置换 #内存不足
自旋锁在什么情况下比会睡眠的互斥锁更划算?
When is a spinlock a better choice than a sleeping mutex?
自旋锁让等待者在循环里反复检查锁标志而不放弃 CPU,代价是空转的时钟周期;互斥锁把线程挂起并触发上下文切换,代价通常在几微秒量级。若临界区极短、预期等待时间小于一次上下文切换的开销,且运行在多处理器上(单核自旋只会白等到时间片用完),自旋更划算。实际实现多用自适应策略:先自旋有限次数,超时后退化为睡眠等待,Linux 的自适应互斥量与 pthread 的 PTHREAD_MUTEX_ADAPTIVE_NP 都是这个思路。
A spinlock busy-waits on a flag without yielding the CPU, paying wasted cycles, while a mutex suspends the thread and pays a context switch typically measured in microseconds. Spinning wins when the critical section is very short, the expected wait is below that switch cost, and there are multiple cores — on a uniprocessor the spinner merely burns its whole time slice. Real systems use adaptive hybrids that spin for a bounded number of iterations and then block, as in Linux adaptive mutexes and pthread's PTHREAD_MUTEX_ADAPTIVE_NP.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Arpaci-Dusseau 夫妇《Operating Systems: Three Easy Pieces》第 28 章 Locks
Arpaci-Dusseau & Arpaci-Dusseau, "Operating Systems: Three Easy Pieces," ch. 28 (Locks)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9781985086593 (2018)
#自旋锁 #互斥锁 #上下文切换 #并发控制
什么是死锁?它发生的四个必要条件是什么?
What is deadlock, and what are its four necessary conditions?
死锁是一组进程互相等待对方持有的资源,永远无法前进。四个必要条件:互斥(资源同一时刻只能一个进程用)、持有并等待(占着资源还等别的)、不可抢占(资源不能被强行拿走)、循环等待(等待关系成环)。打破任一条件即可预防或解除,例如给资源统一编号并按序申请。
Deadlock is a set of processes each waiting on resources held by others, so none can proceed. The four necessary conditions: mutual exclusion (a resource used by one process at a time), hold and wait (holding resources while waiting for more), no preemption (resources cannot be forcibly taken), and circular wait (a waiting cycle). Breaking any condition prevents or resolves it—for instance, numbering resources and requesting them in order.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Coffman 等 1971;Silberschatz 等《操作系统概念》
Coffman et al. (1971); Silberschatz et al., Operating System Concepts
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#死锁 #互斥 #循环等待
虚拟内存和分页是怎样让程序以为自己拥有整片连续内存的?
How do virtual memory and paging make a program think it owns a whole contiguous memory?
操作系统用页表把程序使用的虚拟地址映射到物理内存的页帧,缺页时再从磁盘换入;程序看到的只是一片统一、连续的地址空间。这样既隔离了进程,又让物理内存被灵活复用。
The OS uses a page table to map a program's virtual addresses to physical page frames, fetching from disk on a page fault; the program sees only one uniform, contiguous address space. This isolates processes and lets physical memory be reused flexibly.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Tanenbaum《现代操作系统》;Silberschatz 等《操作系统概念》
Tanenbaum, 'Modern Operating Systems'; Silberschatz et al., 'Operating System Concepts'
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#虚拟内存 #分页 #页表 #缺页
页面置换算法(如 LRU)解决什么问题?
What problem do page replacement algorithms such as LRU solve?
当物理内存已满、又要调入新页时,操作系统必须挑一页换出到磁盘,页面置换算法决定换哪页。LRU(最近最少使用)假设最近很久没用的页将来也少用,优先换它,效果通常较好。理想算法需要知道未来,现实中常用近似 LRU 来权衡开销与命中率。
When physical memory is full and a new page must be brought in, the OS must choose a page to evict to disk, and the page replacement algorithm decides which. LRU (least recently used) assumes a page unused for a long time will stay unused and evicts it first, usually performing well. The ideal algorithm would know the future; in practice approximated LRU balances overhead and hit rate.
难度 专业 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#页面置换 #LRU #虚拟内存
为什么普通程序崩溃不会拖垮整个操作系统?
Why doesn't a crashing application bring down the whole operating system?
CPU 提供用户态与内核态两种特权级别。应用程序跑在用户态,无法直接访问硬件和内核数据结构;一旦越界访问非法地址,MMU 会抛异常,操作系统接管并终止该进程,不影响其他进程。只有系统调用和中断才会切到内核态,由内核验证请求后执行。
CPUs provide user mode and kernel mode with different privilege levels. Applications run in user mode, unable to touch hardware or kernel data structures directly; any illegal access triggers an MMU fault, and the OS takes over to kill only that process. The CPU enters kernel mode only for system calls and interrupts, where the kernel validates and executes the request.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Silberschatz 等《操作系统概念》(Operating System Concepts);Tanenbaum《现代操作系统》
Silberschatz et al., Operating System Concepts; Tanenbaum, Modern Operating Systems
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#用户态 #内核态 #内存保护
操作系统有哪些常见的进程调度算法?
What are common process scheduling algorithms in operating systems?
常见算法包括先来先服务、短作业优先、时间片轮转、优先级调度以及多级反馈队列等。时间片轮转给每个进程公平的小时间片,适合交互式系统;多级反馈队列则按行为动态调整优先级。各有侧重:有的追求吞吐,有的追求响应速度或公平。
Common algorithms include first-come first-served, shortest-job-first, round-robin, priority scheduling, and multilevel feedback queues. Round-robin gives every process a fair time slice and suits interactive systems, while multilevel feedback queues adjust priority by behavior. Each trades off throughput, response time, or fairness differently.
难度 专业 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#调度算法 #操作系统 #进程
实时系统中低优先级的任务为什么会反过来拖住高优先级任务?火星探路者号当年的频繁重启,为何靠调整互斥锁的优先级策略就能根治?
In real-time systems, how can a low-priority task end up stalling a high-priority one, and why did switching the mutex's priority policy permanently fix the repeated resets aboard Mars Pathfinder?
高优先级任务因等待低优先级任务手中的互斥锁而被迫停摆,这种现象就是优先级反转。持锁者本该尽快跑完临界区交还锁,却被与锁无关的中优先级任务抢走CPU,锁迟迟无人释放,阻塞链越拖越长;火星探路者号正是因此屡屡触发看门狗,反复重启整个系统。引入优先级继承后,持锁任务被临时抬升到所有等待者中最高的优先级,迅速跑完临界区归还互斥锁,反转随即消失。
A high-priority task stalls because the mutex it needs is held by a low-priority task — that is priority inversion. The lock holder should finish its critical section quickly and hand the lock back, yet a medium-priority task needing no lock at all preempts it, so the mutex stays stuck and the blocking chain keeps growing; on Mars Pathfinder this repeatedly tripped the watchdog and rebooted the craft. With priority inheritance, the lock holder is temporarily boosted to the highest priority among everything waiting on it, races through its critical section and returns the mutex, and the inversion vanishes.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Cormen, Leiserson, Rivest, Stein,《Introduction to Algorithms》第3版,MIT Press,2009
T. H. Cormen et al., Introduction to Algorithms, 3rd ed., MIT Press, 2009
独立核验依据 · Independent verification: 核验依据 2 ISBN 978-0-262-04630-5
#优先级反转 #优先级继承 #互斥锁
I/O 多路复用(如 select/poll/epoll)解决什么问题?
What problem does I/O multiplexing such as select/poll/epoll solve?
当程序要同时盯住大量网络连接或文件,却不想为每一个都开一个线程时,I/O 多路复用让一个线程同时监视多个描述符,哪个就绪就处理哪个。select/poll 每次都要扫描全部描述符,开销随数量线性增长;epoll 等则只返回就绪项,更适合海量连接。它用单线程高效支撑高并发服务。
When a program must watch many network connections or files at once without spawning a thread per item, I/O multiplexing lets one thread monitor multiple descriptors and handle whichever is ready. select/poll scan all descriptors each time, so cost grows linearly, while epoll and similar return only ready ones and suit huge numbers of connections. It lets a single thread efficiently support highly concurrent services.
难度 专业 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#I/O多路复用 #epoll #高并发
分段和分页有何区别?
What is the difference between segmentation and paging?
分段按程序的逻辑意义(代码段、数据段、栈段)划分不定长的内存块,更贴近程序结构但易产生外部碎片。分页则按固定大小切分,便于分配但和程序逻辑无关。现代系统多用分页,分段只保留少量保护用途。
Segmentation divides memory into variable-length blocks by logical meaning (code, data, stack segments), matching program structure but causing external fragmentation. Paging splits memory into fixed-size blocks, easy to allocate but unrelated to program logic. Modern systems mostly use paging, keeping segmentation only for limited protection purposes.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#分段 #分页 #内存管理
什么是系统调用,用户程序为何需要它?
What is a system call and why do user programs need it?
系统调用是用户程序请求操作系统内核替它做事的受控接口,例如读写文件、创建进程、分配内存。因为硬件资源受内核保护,普通程序不能直接操作,必须通过系统调用进入内核态完成。它既是能力的入口,也是安全隔离的边界。
A system call is the controlled interface by which a user program asks the OS kernel to do something for it, such as reading a file, creating a process, or allocating memory. Because hardware resources are protected by the kernel, normal programs cannot manipulate them directly and must enter kernel mode via a system call. It is both a capability entry point and a security boundary.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#系统调用 #内核 #操作系统
文件是怎么存在硬盘上的?为什么删除大文件也很快?
How are files stored on disk, and why is deleting a big file so fast?
文件系统把磁盘划分成固定大小的块,用索引结构(如 Unix 的 inode)记录文件名、权限、大小和指向数据块的指针。删除文件通常只是清除元数据并把块标记为空闲,数据本身并不清零,所以再大的文件也能瞬间“删掉”。文件内容在块里不一定连续存放。
The file system divides the disk into fixed-size blocks and records each file's name, permissions, size, and block pointers in an index structure such as the Unix inode. Deleting usually just clears the metadata and marks the blocks free without erasing data, which is why even huge files vanish instantly. A file's blocks need not be contiguous.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#文件系统 #inode #磁盘块
什么是死锁?产生死锁的四个必要条件是什么?
What is a deadlock, and what are the four necessary conditions for one?
死锁是指两个或多个进程因相互等待对方持有的资源而永远无法继续执行的状态。科弗曼等人在 1971 年总结出四个必要条件:互斥、持有并等待、不可抢占、循环等待;只有四者同时成立才会出现死锁。打破其中任一条件(如资源有序分配、超时放弃)即可预防或避免死锁。
A deadlock is a state in which two or more processes are permanently blocked, each waiting for a resource held by another. Coffman et al. (1971) identified four necessary conditions: mutual exclusion, hold and wait, no preemption, and circular wait; a deadlock occurs only when all four hold. Breaking any one of them—for example, ordered resource allocation or timed rollback—prevents or avoids deadlock.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Coffman 等 1971;Silberschatz 等《操作系统概念》
Coffman et al. (1971); Silberschatz et al., Operating System Concepts
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#死锁 #互斥 #循环等待 #科弗曼
什么是文件描述符?
What is a file descriptor?
在类 Unix 系统中,文件描述符是内核返回给进程的一个小整数,用来代表一个已打开的文件、管道或网络套接字等 I/O 对象。进程之后读写都靠这个编号,而非文件名。标准输入、输出、错误通常固定为 0、1、2。
In Unix-like systems, a file descriptor is a small integer the kernel gives a process to represent an open file, pipe, or network socket and other I/O objects. The process then reads or writes using that number rather than a file name. Standard input, output, and error are conventionally 0, 1, and 2.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#文件描述符 #I/O #操作系统
常见的文件系统(如 FAT、NTFS、ext4)有何特点?
What characterizes common file systems such as FAT, NTFS, and ext4?
FAT 简单、兼容性极广,但单文件大小和分区容量受限,且无权限管理。NTFS 是 Windows 主流,支持权限、加密、日志和超大文件。ext4 是 Linux 常用文件系统,支持日志、大容量和较好的性能。它们都解决“如何把文件映射到磁盘块”这一问题,但侧重点不同。
FAT is simple and widely compatible but limits file and partition size and lacks permissions. NTFS is the mainstream Windows system, supporting permissions, encryption, journaling, and huge files. ext4 is common on Linux, offering journaling, large capacity, and good performance. All solve mapping files onto disk blocks but with different emphases.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#文件系统 #NTFS #ext4
进程一般会经历哪些状态?
What states does a process typically go through?
典型状态包括新建、就绪、运行、阻塞(等待)和终止。就绪表示已具备运行条件只等 CPU,运行表示正占用 CPU,阻塞表示在等某事件(如 I/O 完成)。操作系统调度器在这些状态间迁移进程。
Typical states are new, ready, running, blocked (waiting), and terminated. Ready means the process can run but awaits the CPU, running means it currently uses the CPU, and blocked means it is waiting for an event such as I/O completion. The OS scheduler moves processes among these states.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#进程状态 #调度 #操作系统
内核态和用户态的区别是什么?
What is the difference between kernel mode and user mode?
CPU 用两种特权级别运行:用户态权限低,只能访问自己的内存和受限指令,应用程序多在此运行。内核态权限高,可执行所有指令、直接操作硬件,操作系统核心代码运行于此。切换二者需要系统调用或中断,目的是防止程序破坏系统。
The CPU runs at two privilege levels: user mode has low rights and can access only its own memory and restricted instructions, where most applications run. Kernel mode has high rights and can execute all instructions and touch hardware directly, where OS core code runs. Switching between them requires a system call or interrupt, preventing programs from corrupting the system.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#内核态 #用户态 #特权级
什么是竞态条件?互斥锁(mutex)如何防止它?
What is a race condition, and how does a mutex prevent it?
竞态条件发生在多个线程并发访问共享数据、且最终结果取决于执行时序时,常导致难以复现的错误。互斥锁通过对临界区加锁,保证同一时刻只有一个线程能进入,从而把并发访问串行化。配合信号量、条件变量等原语,操作系统和编程语言得以安全地协调并发。
A race condition arises when multiple threads access shared data concurrently and the final result depends on execution timing, often causing hard-to-reproduce bugs. A mutex locks a critical section so that only one thread can enter it at a time, serializing the concurrent access. Together with semaphores and condition variables, such primitives let operating systems and languages coordinate concurrency safely.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Tanenbaum《现代操作系统》;Silberschatz 等《操作系统概念》
Tanenbaum, Modern Operating Systems; Silberschatz et al., Operating System Concepts
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#竞态条件 #互斥锁 #并发 #临界区
什么是内核?
What is a kernel?
内核是操作系统的核心部分,运行在特权模式下,直接管理 CPU、内存、设备和进程。应用程序通过系统调用与内核交互。它相当于操作系统的「发动机」,决定了整个系统的行为和安全。
The kernel is the core part of an operating system, running in privileged mode and directly managing the CPU, memory, devices, and processes. Applications interact with it through system calls. It is like the engine of the OS, deciding the system's behavior and security.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#内核 #操作系统 #特权
进程和线程到底有什么区别?
What exactly is the difference between a process and a thread?
进程是资源分配的基本单位,拥有独立的内存空间;线程是 CPU 调度的基本单位,同一进程内的线程共享内存与文件,切换更轻。多线程便于并行处理和共享数据,但也要小心竞态。
A process is the unit of resource ownership with its own memory space; a thread is the unit of scheduling, and threads within a process share memory and files, making context switches lighter. Multithreading eases parallelism and data sharing but risks races.
难度 进阶 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Silberschatz 等《操作系统概念》(Operating System Concepts);Tanenbaum《现代操作系统》
Silberschatz et al., 'Operating System Concepts'; Tanenbaum, 'Modern Operating Systems'
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#进程 #线程 #调度 #共享内存
操作系统怎么让多个程序公平地用CPU?
How does the operating system share the CPU fairly among programs?
调度器把CPU时间切成很短的片(典型几十毫秒),按时间片轮转等策略分配给就绪进程,谁用完就让出。由于切换极快,人感觉所有程序在同时运行。现代系统还会按优先级调整:交互型任务先得到响应,后台计算适当靠后。
The scheduler slices CPU time into short quanta—typically tens of milliseconds—and hands them out to ready processes, often round-robin, forcing a switch when a slice ends. Because switches are so fast, programs appear to run simultaneously. Modern systems also prioritize: interactive tasks respond first while batch computation waits.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
《操作系统概念》(Abraham Silberschatz 等)
Operating System Concepts (Silberschatz et al.)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#调度器 #时间片 #优先级
符号链接和硬链接有什么区别?
What is the difference between a symbolic link and a hard link?
硬链接是同一个 inode 的多个目录项,多个名字指向完全相同的数据,删除一个不影响其他。符号链接(软链接)是一个独立的特殊文件,内容只是指向目标路径,像快捷方式,可跨文件系统、可指向目录。原文件被删后,软链接会失效。
A hard link is another directory entry for the same inode, so several names point to exactly the same data, and removing one does not affect the others. A symbolic link (soft link) is a separate special file whose content is just the target path, like a shortcut; it can cross file systems and point to directories. If the original is deleted, the soft link breaks.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#符号链接 #硬链接 #文件系统
虚拟内存是什么,为什么程序能用比物理内存更大的空间?
What is virtual memory and why can programs use more space than physical RAM?
虚拟内存让每个程序看到一片独立、连续的地址空间,由操作系统和硬件(MMU)映射到零散的物理内存,必要时把不常用的页换出到硬盘。这样单个程序可用的地址空间可以远大于实际内存容量。它既扩大了可用内存,也实现了程序间的内存隔离。
Virtual memory gives each program its own contiguous view of addresses that the OS and hardware (MMU) map onto scattered physical memory, swapping less-used pages to disk when needed. This lets a single program's addressable space far exceed actual RAM. It both enlarges usable memory and isolates programs from one another.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#虚拟内存 #分页 #操作系统
什么是僵尸进程?
What is a zombie process?
子进程结束后,其退出状态需由父进程通过“等待”系统调用回收;若父进程迟迟不回收,子进程就留下一个只占进程表项、不再运行但未被清除的僵尸进程。僵尸本身不消耗 CPU 和内存,但积累过多会耗尽进程号。让父进程正确回收,或父进程退出后由 init 接管,可消除它们。
When a child process ends, its exit status must be reaped by the parent via a wait system call; if the parent delays, the child lingers as a zombie that occupies only a process-table slot, no longer runs but is not cleared. A zombie consumes no CPU or memory, but too many can exhaust process IDs. Proper reaping by the parent, or letting init adopt it when the parent exits, removes them.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#僵尸进程 #进程 #操作系统
Linux 内存耗尽时,OOM Killer 按什么标准决定杀掉哪个进程?
When Linux runs out of memory, how does the OOM killer pick which process to kill?
内核为每个候选进程计算一个 oom_score,主要依据其常驻内存、交换区与页表占用相对系统总内存的比例,因此最占内存的进程通常首先被选中。管理员可以通过 /proc/<pid>/oom_score_adj 在 -1000 到 1000 之间调整权重,取 -1000 表示永不被选。内核线程与 init 受保护;被选中的进程收到的是 SIGKILL 而非 SIGTERM,没有机会保存状态,这也是数据库通常配置负的 oom_score_adj 的原因。
The kernel computes an oom_score for each eligible task, dominated by its resident memory, swap and page-table usage as a fraction of total memory, so the biggest consumer is usually chosen. Administrators bias the decision through /proc/<pid>/oom_score_adj in the range -1000 to 1000, where -1000 makes a task immune. Kernel threads and init are protected, and the victim receives SIGKILL rather than SIGTERM, so it cannot flush state — which is why databases are commonly given a negative oom_score_adj.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
Linux 内核官方文档 Documentation/filesystems/proc.rst(oom_score_adj 一节)与源码 mm/oom_kill.c
Linux kernel documentation, Documentation/filesystems/proc.rst (oom_score_adj) and mm/oom_kill.c
#OOM Killer #内存回收 #Linux内核 #oom_score_adj
操作系统里的“缓冲区”和“缓存”是一回事吗?
Are buffers and caches the same thing in an operating system?
不完全一样。缓冲区(buffer)主要用来临时存放正在传输中的数据,平滑生产者和消费者速度差异,比如写盘前先攒一批。缓存(cache)则是为了加快将来访问而保存已读取数据的副本。二者都占用内存,但目的不同:一个为“暂存”,一个为“提速”。
Not exactly. A buffer temporarily holds data in transit to smooth speed differences between producer and consumer, such as batching writes before hitting disk. A cache keeps copies of already-read data to speed up future access. Both use memory but for different aims: one for staging, the other for acceleration.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#缓冲区 #缓存 #操作系统
什么是 CPU 调度?
What is CPU scheduling?
CPU 调度决定在多个就绪任务中,下一个由哪个占用处理器,目标是提高吞吐、降低等待时间。常见策略有先来先服务、时间片轮转、优先级调度等。调度算法的选择会影响系统的响应速度和公平性。
CPU scheduling decides, among ready tasks, which one uses the processor next, aiming to raise throughput and lower waiting time. Common policies include first-come-first-served, round-robin, and priority scheduling. The chosen algorithm affects responsiveness and fairness.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#调度 #CPU #算法
操作系统中的调度是什么?
What is scheduling in an operating system?
调度是操作系统决定哪个进程或线程在何时使用 CPU 的机制。常见策略有先来先服务、时间片轮转、最短作业优先和优先级调度,目标是兼顾吞吐、响应和公平。
Scheduling is the OS mechanism that decides which process or thread uses the CPU and when. Common policies include first-come first-served, round-robin, shortest-job-first, and priority scheduling, aiming to balance throughput, responsiveness, and fairness.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
《操作系统概念》(Abraham Silberschatz 等)
Operating System Concepts (Silberschatz et al.)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#调度 #CPU #时间片
什么是信号量?
What is a semaphore?
信号量是由 Dijkstra 提出的同步原语,用一个可原子增减的整数表示可用资源数量。P 操作申请资源、V 操作释放资源,常用来解决多线程间的互斥与协作问题。
A semaphore, introduced by Dijkstra, is a synchronization primitive using an integer that can be changed atomically to represent available resources. The P operation acquires a resource and V releases it, commonly used for mutual exclusion and coordination among threads.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
《操作系统概念》(Abraham Silberschatz 等)
Operating System Concepts (Silberschatz et al.)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#信号量 #同步 #互斥
单片机让 CPU 逐字节搬运串口或 ADC 数据既慢又费时,把活儿交给 DMA 后处理器立刻腾出了手,DMA 到底替 CPU 包揽了什么?
On a microcontroller, having the CPU ferry UART or ADC bytes one at a time is slow and wasteful, yet delegating the job to DMA frees the processor almost instantly — what exactly does DMA take over for the CPU?
DMA 控制器接管了数据在内存与外设之间的搬运:CPU 只需设置一次源地址、目标地址和传输长度,之后的整个传送过程都不再占用处理器周期。配置完毕 CPU 立即返回,继续执行其他任务或进入休眠省电;外设就绪时发出请求,DMA 经总线仲裁直接成块读写,全部搬完才上报一次完成中断。原先逐字节触发的海量中断被压缩成整批一次,CPU 占用率骤降,实时响应与功耗同步改善,这正是它被称作片上搬运工的原因。
A DMA controller takes over shuttling data between memory and peripherals: the CPU programs a source address, a destination address and a transfer length once, and the whole move afterward consumes no processor cycles at all. Configuration done, the CPU immediately returns to other work or sleeps to save power; when the peripheral signals readiness, the DMA arbitrates for the bus and moves the block wholesale, raising a single completion interrupt once everything lands. Thousands of per-byte interrupts collapse into one batch notification, CPU load plummets, latency and energy improve together — hence its nickname, the chip's porter.
难度 进阶 · 适合 初中(12-15)
CC BY 4.0 · 已核验 · Verified 2026-11-03
来源 · Source
W. Wolf,《Computers as Components: Principles of Embedded Computing System Design》,Morgan Kaufmann,2008年;R. Kamal,《Embedded Systems: Architecture, Programming and Design》,McGraw-Hill,2008年
W. Wolf, Computers as Components: Principles of Embedded Computing System Design, Morgan Kaufmann, 2008; R. Kamal, Embedded Systems: Architecture, Programming and Design, McGraw-Hill, 2008
独立核验依据 · Independent verification: 核验依据 1 ARCHIVE 标识 isbn_2900123743977:Computers as Components: P
#直接内存访问 #中断开销 #总线仲裁
什么是上下文切换,它为什么有开销?
What is a context switch and why does it have overhead?
上下文切换指 CPU 从一个进程或线程转到另一个时,保存当前运行状态(寄存器、程序计数器等)并恢复下一个状态的过程。因为要读写内核数据、刷新相关缓存,且期间真正干活的指令变少,所以频繁切换会降低效率。
A context switch is when the CPU moves from one process or thread to another by saving the current run state (registers, program counter, etc.) and restoring the next one. Because it touches kernel data and flushes relevant caches while doing less useful work, frequent switching lowers efficiency.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#上下文切换 #调度 #操作系统
分页(paging)是怎么管理内存的?
How does paging manage memory?
分页把物理内存和虚拟地址空间都切成固定大小的“页”,用页表记录虚拟页到物理页框的映射。程序按虚拟页号访问,硬件查表得到真实地址,从而允许物理内存零散分配而不必连续。它也方便了换页和内存保护。
Paging divides both physical memory and the virtual address space into fixed-size pages, with a page table recording the mapping from virtual pages to physical frames. The program addresses by virtual page number and the hardware looks it up to get the real address, allowing scattered physical allocation without needing contiguous memory. It also eases swapping and memory protection.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#分页 #虚拟内存 #操作系统
文件系统是做什么的?
What does a file system do?
文件系统负责在存储设备上组织、命名、存放和检索文件,让用户可以按文件名而非物理扇区来存取数据。它还记录权限、大小、修改时间等元数据,并管理空间分配。没有文件系统,磁盘只是一片难以使用的原始字节。
A file system organizes, names, stores, and retrieves files on a storage device so users can access data by name rather than by physical sector. It also records metadata such as permissions, size, and modification time and manages space allocation. Without a file system, a disk is just raw, hard-to-use bytes.
难度 入门 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#文件系统 #存储 #操作系统
操作系统主要做什么?什么是上下文切换?
What does an operating system mainly do, and what is a context switch?
操作系统是管理硬件资源(CPU、内存、磁盘、外设)并为程序提供运行环境的系统软件,典型职责包括进程调度、内存管理和文件读写。上下文切换指 CPU 从一个进程或线程切换到另一个时,保存当前现场(寄存器、程序计数器等)并恢复目标现场的过程。频繁切换会带来开销,但正是它让多个程序看起来能同时运行。
An operating system is system software that manages hardware resources (CPU, memory, disk, devices) and provides a runtime environment for programs, with duties including process scheduling, memory management, and file I/O. A context switch is the act of CPU saving the current execution state (registers, program counter) and restoring that of another process or thread. Frequent switches incur overhead, yet they are what makes multiple programs appear to run at once.
难度 入门 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
Silberschatz 等《操作系统概念》(Operating System Concepts);Tanenbaum《现代操作系统》
Silberschatz et al., Operating System Concepts; Tanenbaum, Modern Operating Systems
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#操作系统 #进程调度 #上下文切换 #资源管理
CPU 是做什么的?
What does the CPU do?
CPU 是电脑的大脑,负责一条条地执行指令、做加减乘除等运算。你点的每个操作都要靠它快速处理,就像人脑思考并指挥身体行动一样。
The CPU is the computer's brain: it executes instructions one by one and performs arithmetic like addition and multiplication. Every action you trigger is processed by it, much like a mind that thinks and directs the body.
难度 入门 · 适合 幼儿(3-6)
CC BY 4.0 · 已核验 · Verified 2026-10-04
来源 · Source
《操作系统概念》(Abraham Silberschatz 等)
Operating System Concepts (Silberschatz et al.)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780470577233 (2019)
#CPU #处理器 #运算
电脑的「睡眠」和「休眠」到底有什么不一样?
What is the real difference between putting a computer to sleep and hibernating it?
睡眠对应 ACPI 的 S3 状态:CPU 停止、硬盘停转,但内存持续供电以保存现场,因此恢复只要一两秒,代价是一旦断电内容就丢失。休眠对应 S4 状态:系统把整个内存内容写进硬盘上的休眠文件后完全断电,恢复时再读回来,因此几乎不耗电但唤醒较慢,还需要与内存等量的磁盘空间。Windows 的快速启动是混合方案,只把内核会话写盘,速度和耗电都介于两者之间。
Sleep is ACPI state S3: the CPU halts and disks spin down, but RAM keeps drawing power to hold your session, so resume takes a second or two and everything is lost if power is cut. Hibernation is S4: the full memory image is written to a file on disk and the machine powers off completely, so it draws essentially nothing but wakes more slowly and needs disk space equal to installed RAM. Windows fast startup is a hybrid that hibernates only the kernel session, landing between the two in both speed and power draw.
难度 入门 · 适合 小学高段(9-12)
CC BY 4.0 · 已核验 · Verified 2026-11-03
来源 · Source
UEFI Forum《Advanced Configuration and Power Interface (ACPI) Specification, Version 6.5》第 16 章
UEFI Forum, "Advanced Configuration and Power Interface (ACPI) Specification, Version 6.5," ch. 16
独立核验依据 · Independent verification: 核验依据 1 ARCHIVE 标识 acpi-specification-version-6.5:Advanced Confi
#睡眠 #休眠 #ACPI #电源管理
守护进程是什么?
What is a daemon process?
守护进程是在后台运行、通常不依赖终端的系统服务进程,比如网络服务、日志服务、定时任务。它们在系统启动时拉起,长期待命处理请求或周期性工作。用户一般不直接与之交互,而是通过它提供的服务间接使用。
A daemon is a background system service process that usually has no controlling terminal, such as networking, logging, or scheduling services. They are launched at system start and stand by to handle requests or run periodic work. Users rarely interact with them directly, instead using the services they provide.
难度 入门 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23 · 2 条独立证据
来源 · Source
Tanenbaum & Bos,《Modern Operating Systems》第4版,Pearson,2014
A. S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed., Pearson, 2014
独立核验依据 · Independent verification: 核验依据 2 OPENLIBRARY 标识 /works/OL1970688W:Modern Operating System
#守护进程 #后台 #操作系统