[toc]
线程进程区别
进程的经典定义:一个执行中的程序的实例。
进程是操作系统分配 CPU 时间、内存资源的最小单位,而线程是操作系统调度的最小单位。这样就实现了同个进程中的线程共享该进程的资源,尤其是虚拟内存空间,但是每个线程拥有自己的逻辑流。
在 Linux 中,线程就是特殊的进程,每个线程有唯一的进程描述符,从内核角度看,线程除了与其他进程共享地址空间等资源外,与进程类似。
每个线程拥有独立的程序计数器 PC,线程栈、和寄存器。
进程间通信方式
虚拟内存理解
虚拟内存可以理解为磁盘上连续 N 个字节大小的单元组成的数组,每个字节用唯一的逻辑地址作为索引,而虚拟内存的数据被缓存在主存中。
三个作用:
- 缓存
- 内存管理
- 内存保护