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 ...
随机推荐
- Brain Network (medium)(DFS)
H - Brain Network (medium) Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- 6.2-SingletonBeanRegistry-DefaultSingletonBeanRegistry
SingletonBeanRegistry package org.springframework.beans.factory.config; public interface SingletonBe ...
- 3.设计模式----TemplateMethod模式
模板模式,其实是一种思想,在开发中有很多地方用到模板,因为毕竟我们不可能每一个都一出一段!一个模板,填充不同,出来效果也是不一样! 准备画个时序图的,没找到工具,过几天补上! 模板模式在出现bug时候 ...
- Netty 源码(ChannelHandler 死磕)
精进篇:netty源码死磕5 - 揭开 ChannelHandler 的神秘面纱 目录 1. 前言 2. Handler在经典Reactor中的角色 3. Handler在Netty中的坐标位置 4 ...
- centos安装 Falcon+
1:环境 准备 : 安装 go环境 :下载 - Golang中国 参照 :http://www.cnblogs.com/Amos-Turing/p/8494250.html 安装 mysql 安装 r ...
- PHP网站在Linux服务器上面的安全配置
本文详细总结了PHP网站在Linux服务器上面的安全配置,包含PHP安全.mysql数据库安全.web服务器安全.木马查杀和防范等,很好很强大很安全. PHP安全配置 1. 确保运行php的用户为一般 ...
- 在C语言中使用syslog打印日志到日志文件
参见 <unix 环境高级编程>第13 章 精灵进程 Syslog为每个事件赋予几个不同的优先级: LOG_EMERG——紧急情况 LOG_ALERT——应该被立即改正的问题,如系统数据库 ...
- LyX中文配置
环境:OS X 10.9; MacTeX-2014; LyX Version 2.1.0 LyX是一个“WYSIWYM”(What You See Is What You Mean)的文字排版系统.其 ...
- 查看mysql支持的存储引擎
查看mysql支持的存储引擎 show engines\G;
- SpringBoot学习笔记(4):与前端交互的日期格式
SpringBoot学习笔记(4):与前端交互的日期格式 后端模型Date字段解析String 我们从前端传回来表单的数据,当涉及时间.日期等值时,后端的模型需将其转换为对应的Date类型等. 我们可 ...