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 ...
随机推荐
- Python菜鸟之路:Python基础——函数
一.函数 1. 简介 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段.函数能提高应用的模块性,和代码的重复利用率. 2. 组成 函数代码块以 def 关键词开头,后接函数名和圆括号( ...
- Android系统移植与调试之------->安装apk时出现错误Failure [INSTALL_FAILED_DEXOPT]问题解决的方法
在android4.0源码里面编译出来apk后,用adb install (或adb install -r 重装)安装时,报错[INSTALL_FAILED_DEXOPT]. xu@xu-PC:~$ ...
- LeetCode:移除K位数字【402】
LeetCode:移除K位数字[402] 题目描述 给定一个以字符串表示的非负整数 num,移除这个数中的 k 位数字,使得剩下的数字最小. 注意: num 的长度小于 10002 且 ≥ k. nu ...
- NVM安装配置
http://www.kancloud.cn/summer/nodejs-install/71975 配置源 http://www.cnblogs.com/kaiye/p/4937191.html 安 ...
- bootstraptable的 showFooter属性
如果想在表格最下面显示统计的信息可以使用这个属性 首先 先在表格加上这个属性 showFooter:true, 然后 在需要的列里面新增属性 footerFormatter 设置列的名称 然后在需 ...
- java入门了解09
1.JDK5新功能 (一).静态导入 import static java.lang.System.out; 使用时:直接写调用out()方法 (二).增强的for循环 只能用在数组:或是实现了Ite ...
- XP最高支持IE8
1.https://www.microsoft.com/zh-CN/download/details.aspx?id=24488 适用于 Windows XP 的 Internet Explorer ...
- django实现用户注册、登录、退出
视图 from django.contrib import auth from django.contrib.auth.models import User from django.views.dec ...
- C++(二)— STL容器的基本用法
1.vector基本操作 关于vector简单的讲就是一个动态增长的数组,里面有一个指针指向一片连续的内存空间,当空间装不下的时候会自动申请一片更大的空间(空间配置器)将原来的数据拷贝到新的空间,然后 ...
- Unity3D之Mesh(三)绘制四边形
前言: 由於之前的基本介紹,所以有關的知識點不做贅述,只上案例,知識作爲自己做試驗的記錄,便於日後查看. 步驟: 1.創建一個empty 的gameobject: 2.添加一個脚本給這個game ob ...