Program Thread 和 Process的不同点
- Thread is for execution
- Kernel level thread, physical parallelism
- Cores Divide work amount of physical cores / CPU
- Load balancing
- Data Splitting
- Which will lead to data dependency coodination and message passing
- Bad thing for multiple cores is this is hard for Testing and debugging
- User level thread only have logical parallelism
- Example, Read from user input is blocking; we have to work on it to make it logical parallelism
- Kernel level thread, physical parallelism
- Process is for resource
What is Program
Program是一个存在disk中且断电或重启不会消失可执行文件,存储在存储媒介中,以实体文件的形态存在
A program is an executable file residing on the disk (secondary storage) in a directory. It is also termed as a set of instructions stored in the secondary storage device that are intended to carry out a specific job. It is read into the primary memory and executed by the kernel.
本文来自 Abbymz 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/Abby210/article/details/51225034?utm_source=copy
或者可以称之为persistently 的文件,断电也不会消失。
What is Process ?
当program被执行之后,就变成了进程。执行者的权限和程序所需的资料都会载入到内存中,OS会给予这些内存单元一个pid。
Unit of resource ownership (allocation) and unit of protection
| text, Code of Programmer |
|---|
| Data |
| Heap |
| Stack |
一个program可以创建出很多个进程,关机或停电会死掉
Process的组成
- Permission user or kernel
- Priority
- Files
- ID
- PID
- PPID
- Folk
- UserID
- Protected access to
- Processors
- other process
- Files
- I/O
- A virtual space that holds the process image
What is Thread ?
线程称之为Lightweight Process,一个进程可以有多个线程,他们共享一片内存
- has access to the same data
- When one thread alters a data, other threads see the results
- When one thread open a file, other threads can also access that file.
Unit of dispatch or unit of execution
多线程的好处
- 开启线程要快于开启进程
- 关闭线程要快于关闭进程
- 切换线程要快于切换进程
- 线程可以相互通讯
什么叫Multithreading
The ability of an OS to support multiple, concurrent paths of execution within a single process.
Process and thread states
- Ready
- new process usually set as read state
- At this time scheduler is not pick it up yet.
- If it get picked by scheduler and running in CPU, then goes to Running State
- If it get external event, something like lock, then goes to block
- Running,
- Scheduler picked it up, and CPU is run this instruction
- If it get finished, goes to Exit states
- If it get IO interrupts, goes to ready, blocked status
- If it can not get the resource which is conflict with other process, goes to deadlock
- Scheduler picked it up, and CPU is run this instruction
- Block
- If it lock (wait able ) is release, or IO is completed, then goes to Ready
- Deadlock
- Exit (Zombie State)
- When process is finished, waiting for cleaning up
How Deadlock happen ?
- When process A has resource a, and it need resource b from process B.
- At the same time, process B need resource a from A
- Then those process gonna have deadlock due to both of them can get the resource they need.
Reference
https://slideplayer.com/slide/5219996/
想要看到更多玮哥的学习笔记、考试复习资料、面试准备资料?想要看到IBM工作时期的技术积累和国外初创公司的经验总结?
敬请关注:
Program Thread 和 Process的不同点的更多相关文章
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
早晨宁波那边的IT人员打电话告知数据库无法访问了.其实我在早晨也发现Ignite监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...
- [CareerCup] 16.1 Thread and Process 线程和进程
16.1 What's the difference between a thread and a process? 进程Process是程序执行时的一个实例.一个进程是被分配系统资源的独立单元,每个 ...
- It is not based on WSGI, and it is typically run with only one thread per process.
Tornado Web Server — Tornado 5.1.1 documentation http://www.tornadoweb.org/en/stable/
- Linux Process/Thread Creation、Linux Process Principle、sys_fork、sys_execve、glibc fork/execve api sourcecode
相关学习资料 linux内核设计与实现+原书第3版.pdf(.3章) 深入linux内核架构(中文版).pdf 深入理解linux内核中文第三版.pdf <独辟蹊径品内核Linux内核源代码导读 ...
- process vs thread
process vs thread http://blog.csdn.net/mishifangxiangdefeng/article/details/7588727 6.进程与线程的区别:系统调度是 ...
- Difference between Process and thread?
What are the differences between a process and a thread? How are they similar? How can 2 threads com ...
- 一个进程(Process)最多可以生成多少个线程(Thread)
1.进程中创建线程的限制 默认情况下,一个线程的栈要预留1M的内存空间,而一个进程中可用的内存空间只有2G,所以理论上一个进程中最多可以开2048个线程,但是内存当然不可能完全拿来作线程的栈,所以实际 ...
- 如何执行一条命令在C#里面。Process
Download source - 4.15 KB Introduction It is normal practice to open the Windows command prompt and ...
- How to Analyze Java Thread Dumps--reference
原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...
随机推荐
- 后端开发实践——Spring Boot项目模板
在我的工作中,我从零开始搭建了不少软件项目,其中包含了基础代码框架和持续集成基础设施等,这些内容在敏捷开发中通常被称为"第0个迭代"要做的事情.但是,当项目运行了一段时间之后再来反 ...
- ES 19 - Elasticsearch的检索语法(_search API的使用)
目录 1 Search API的基本用法 1.1 查询所有数据 1.2 响应信息说明 1.3 timeout超时机制 1.4 查询多索引和多类型中的数据 2 URI Search的用法 2.1 GET ...
- [区块链] 拜占庭将军问题 [BFT]
背景: 拜占庭将军问题很多人可能听过,但不知道具体是什么意思.那么究竟什么是拜占庭将军问题呢? 本文从最通俗的故事讲起,并对该问题进行抽象,并告诉大家拜占庭将军问题为什么在区块链领域作为一个重点研究问 ...
- ES 11 - 配置Elasticsearch的映射 (mapping)
目录 1 映射的相关概念 1.1 什么是映射 1.2 映射的组成 1.3 元字段 1.4 字段的类型 2 如何配置mapping 2.1 创建mapping 2.2 更新mapping 2.3 查看m ...
- 两个月的Java实习结束,继续努力
前言 只有光头才能变强 2018年8月30日,今天我辞职了.在6月25号入职,到现在也有两个月时间了. 感受: 第一天是期待的:第一次将项目拉到本地上看的时候,代码很多,有非常多的模块,模块下又有da ...
- SignalR第一节-在5分钟内完成通信连接和消息发送
前言 首先声明,这又是一个小白从入门到进阶系列. SignalR 这个项目我关注了很长时间,中间好像还看到过微软即将放弃该项目的消息,然后我也就没有持续关注了,目前的我项目中使用的是自己搭建的 Web ...
- 30分钟玩转Net MVC 基于WebUploader的大文件分片上传、断网续传、秒传(文末附带demo下载)
现在的项目开发基本上都用到了上传文件功能,或图片,或文档,或视频.我们常用的常规上传已经能够满足当前要求了, 然而有时会出现如下问题: 文件过大(比如1G以上),超出服务端的请求大小限制: 请求时间过 ...
- css 四周边框角加粗效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SQL注入渗透实战
概述: 判断注入点: http://www.xxxxx.com/page.php?pid=42 and 1=1 #true http://www.xxxxx.com/page.php?pid=42 a ...
- 前端基于Canvas生成等值面的方案
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 在之前的项目中,我们做过基于PM2.5的站点监测数据对全区域进 ...