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 ...
随机推荐
- 1、Codevs 必做:2833、1002、1003、2627、2599
2833 奇怪的梦境 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description Aiden陷入了一个奇怪的梦境:他被困 ...
- 如何实现模拟器(CHIP-8 interpreter) 绝佳杰作.
转自 http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/ How to write an ...
- SpringBoot_集成Shiro后获取当前用户
//SecurityUtils.getSubject().getPrincipal(); 就可以获取了 protected User getCurrentUser(){ return (User) ...
- 坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException
今天整整一个上午都在和hibernate做斗争,早上一来,继续昨天的项目开发,发现spring项目不能启动,从错误中看是hibernate错误,多半是hibernate配置有错误,关键是错误提示中显示 ...
- 用Pythonic方式来思考
一门语言的编程习惯是由用户来确立的.这些年来,Python开发者用Pythonic这个形容词来描述那种符合特定风格的代码. 这种Pyhtonic风格,既不是严密的规范,也不是由编译器强加给开发者的规则 ...
- Kattis - fire2 【BFS】
第二组样例: 题意 给出一个起始位置,然后要跑到这幢建筑物的外面,上下左右四个方向,只要是空地 就可以走 走一步 花费一秒 然后有若干串火苗,每一秒钟 会向上下左右 四个方向的空地 蔓延 但是 逃跑的 ...
- Linux系统中UI库curse.h不存在问题——贪吃蛇为例
1. 问题 大家在用Linux写程序时,大家会使用Linux gcc编译器中的头文件curse.h.但往往一般的发行版中都没有默认安装这个头文件,需要大家自行安装.最近遇到这个问题,如下: Red ...
- 20145229吴姗珊《Java程序设计》2天总结
20145229吴姗珊<Java程序设计>2天总结 教材学习内容总结 异常处理 1.使用try.catch Java中所有错误都会被包装成对象,可以尝试(try)执行程序并捕捉(catch ...
- Linux 上关于iptables
有几个命令: 1.service iptables staus 2.service iptables start 3.service iptables restart 有个配置文件/ec ...
- 申请内存的方式(1,malloc/free;2,new/delete)
一.malloc/free的方式 // 4个int 的大小int *p = (int*) malloc(16); for (int i = 0; i < 4; ++i) { p[i] = i; ...