• 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
  • 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
  • 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工作时期的技术积累和国外初创公司的经验总结?

敬请关注:

玮哥的博客 —— CSDN的传送门

玮哥的博客 —— 简书的传送门

玮哥的博客 —— 博客园的传送门

Program Thread 和 Process的不同点的更多相关文章

  1. 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监控下的宁波的数据库服务器出现了异常,但是当时正在检查查看其它服务器发过来的各类邮件,还没等到我去确认具体情 ...

  2. [CareerCup] 16.1 Thread and Process 线程和进程

    16.1 What's the difference between a thread and a process? 进程Process是程序执行时的一个实例.一个进程是被分配系统资源的独立单元,每个 ...

  3. 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/

  4. 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内核源代码导读 ...

  5. process vs thread

    process vs thread http://blog.csdn.net/mishifangxiangdefeng/article/details/7588727 6.进程与线程的区别:系统调度是 ...

  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 ...

  7. 一个进程(Process)最多可以生成多少个线程(Thread)

    1.进程中创建线程的限制 默认情况下,一个线程的栈要预留1M的内存空间,而一个进程中可用的内存空间只有2G,所以理论上一个进程中最多可以开2048个线程,但是内存当然不可能完全拿来作线程的栈,所以实际 ...

  8. 如何执行一条命令在C#里面。Process

    Download source - 4.15 KB Introduction It is normal practice to open the Windows command prompt and ...

  9. How to Analyze Java Thread Dumps--reference

    原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...

随机推荐

  1. CentOS7搭建本地YUM仓库,并定期同步阿里云源

    CentOS7同步阿里云镜像rpm包并自建本地yum仓库 系统环境 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # u ...

  2. WordPress怎样设置菜单栏旋转小图标

    最近我在浏览别的博客的文章时,无意间发现了一个很好看的小装饰.那就是在WordPress菜单栏上的小图标.于是我研究了研究,弄到了设置方法之后决定把它分享出来. 菜单栏的小图标 设置步骤: 1, 我们 ...

  3. 把时间留给重要的事——Markdown 模板功能上线

    你是否遇到过因为同事在任务中过于放飞自我而感到头疼?或者经历过因为内容描写的不系统而导致关键信息被忽视? 现在,CODING Markdown 模板功能将帮助你解决这些困扰. 功能介绍 CODING ...

  4. 度分秒转换十进制度 之Excel实现

    我们都知道,1°=60′,1′=60″,1°=3600″.那么,轻而易举容易计算:112°18′37.6″=112+18/60+37.6/3600≍112.3104444°这当然是有参考价值的,比如爬 ...

  5. 了解git的命令行使用

    git现在已经是非常大众的版本管理工具了,如果在windows下用vs这种ide,已经可以很简单的点点鼠标就完成大部分工作了. 但是在某些特殊情况用命令行时,还是需要了解很多命令的. 安装 linux ...

  6. Mysql8 安装过程及安装过程系列问题记录

    前言: 今天,想装个高版本一点的mysql试试,于是下载了一个mysql8的zip版本. 地址:https://dev.mysql.com/downloads/file/?id=484900 没想到安 ...

  7. 一分钟上手artTemplate

    一分钟上手artTemplate artTemplate是腾讯开源的前端模版引擎.之前做hue二次开发,只接触过用python写的mako模版引擎,所以之前对前端模版引擎了解不是很多. 这次因为pm叫 ...

  8. Java使用Try with resources自动关闭资源

    Try-with-resources Try-with-resources是Java7中一个新的异常处理机制,它能够很容易地关闭在try-catch语句块中使用的资源. 利用Try-Catch-Fin ...

  9. js原生数组去重

    // ['c', 'a', 'z', 'a', 'x', 'a', 'x', 'c', 'b']; 取消重复的元素 数组去重 (for循环) // 把旧数组里面 不重复的元素选取出来放到新数组中 重复 ...

  10. 【Android Studio安装部署系列】十六、Android studio在layout目录下新建子目录

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 一般用于分类显示不同模块的layout布局文件. 在res/layout文件夹下创建子目录 res/layout鼠标右键——New— ...