Operating System-Thread(2) Multi-Process-Parallel vs Multi-Thread-Parallel
本文主要介绍线程的模型
一、Multi-Process-Parallel vs Multi-Thread-Parallel

多进程的并行:CPU在多个进程之间进行切换,系统给人一种多个进程在并行执行的假象。
多线程的并行:CPU在多个线程之间进行切换,系统给人一种多个线程在并行执行的假象。
进程是资源分配的基本单元,线程是CPU执行的基本单元。
二、进程和线程所独占的资源

前一篇文章已经说了,同一个进程的线程共享进程的资源,在进程中引入线程就是为了让多个执行(线程)共享资源,协调工作完成任务。
但是每个线程有属于自己独享的属性,如上图所示,最为重要的是栈。栈的示意图如下图所示。

线程的栈保存者已经调用但是还没有返回的程序(递归为什么会浪费资源,就是因为有大量的程序调用保存在运行线程的栈中)。栈用于保存执行历史。
假设程序A调用程序B,程序B调用程序C,C调用D,当D在执行时,栈中的数据应该是ABCD,当D执行完毕后,D会出栈,以此类推,A执行返回后栈的数据就会清空。
三、创建新线程
当一个进程启动后,进程至少包含一个线程,该线程可以通过系统调用创建新的线程,创建新线程只需要指定想让该线程执行的方法(Procedure),而无需指定该新线程的地址空间,因为新线程会自动在创建他的线程的地址空间下运行(也就是所属进程的地址空间)。
被创建的线程可以称之为子线程,但是线程之间的hierarchy也不是很重要。
Operating System-Thread(2) Multi-Process-Parallel vs Multi-Thread-Parallel的更多相关文章
- [Chapter 3 Process]Practice 3.3 Discuss three major complications that concurrent processing adds to an operating system.
3.3 Original version of Apple's mobile iOS operating system provied no means of concurrent processi ...
- python multi process multi thread
muti thread: python threading: https://docs.python.org/2/library/threading.html#thread-objects https ...
- 如何定位“Operating system error 32(failed to retrieve text for this error. Reason: 15105)”错误中被占用的文件
之前在这篇"Operating system error 32(failed to retrieve text for this error. Reason: 15105)"博 ...
- InnoDB: Operating system error number 87 in a file operation. 错误87的解决方法
InnoDB: Operating system error number 87 in a file operation. 错误87的解决方法 140628 8:10:48 [Note] Plugi ...
- Modern Operating System
No one can do all things, learn to be good at use what others already did. Most computers have two m ...
- The threads in the thread pool will process the requests on the connections concurrently.
https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html Most of the executor implem ...
- Operating system management of address-translation-related data structures and hardware lookasides
An approach is provided in a hypervised computer system where a page table request is at an operatin ...
- Operating system coordinated thermal management
A processor's performance state may be adjusted based on processor temperature. On transitions to a ...
- Full exploitation of a cluster hardware configuration requires some enhancements to a single-system operating system.
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION Operating System Desi ...
- osquery An Operating System Instrumentation Framewor
catalog . Getting Started . install guide for OS X and Linux . Features Overview . Logging . query e ...
随机推荐
- EF之POCO应用系列3——延迟加载
EF之POCO应用系列4——延迟加载 当我们进行查询的时候,哪些关系的数据将会被加载到内存呢?所有相关的对象都需要吗?在一些场合可能有意义,例如,当查询的实体仅仅拥有一个相关的子实体,但是,多数情况下 ...
- 配置过滤器filter对跨站脚本攻击XSS实现拦截
1.web.xml中配置filter [html] view plain copy <filter> <filter-name></filter-name> & ...
- rate limiter - system design
1 问题 Whenever you expose a web service / api endpoint, you need to implement a rate limiter to preve ...
- HealthKit详解
1. 导入HealthKit框架 #import <HealthKit/HealthKit.h> 2. 判断设备是否支持HealthKit HealthKit是iOS8加入的API Hea ...
- iOS设备获取总结
1.获取iOS设备的各种信息 // 这个方法后面会列出来 NSString *deviceName = [self getDeviceName]; NSLog(@"设备型号-->%@& ...
- thinkphp5, 模板继承、模板布局
---------------------------------------------------------------------------------------------------- ...
- Tensorflow 初级教程(二)
一.Tensorflow 扩展功能 1.自动求导 2.子图的执行 3.计算图控制流 4.队列/容器 Tensorflow 自动求导 当计算tensor C关于tensor W的梯度时,会先寻找从W到C ...
- 改善程序与设计的55个具体做法 day7
条款18:让接口容易被正确使用,不易被误用 这里说的接口是广义上的接口,即包括但不限于函数接口.类接口.template接口等,每一种接口都是客户与你的代码进行交互的手段. 我们对客户的所谓“资质或水 ...
- Jmeter使用文档(windows)
1. 安装jdk并配置环境变量 以1.8为例: (1)安装jdk1.8; (2)在系统变量里点击新建,变量名填写JAVA_HOME,变量值填写JDK的安装路径“C:\Program Files\Jav ...
- c的详细学习(11)文件
为了提高数据输入/输出的处理效率,可以将程序运行时所需要的原始数据从文件中读取,并将程序运行的结果写入到文件中. (1)文件概述 1)基本概念 文件是指存储在外部介质上数据的集合,可以 ...