并发编程基础 Lecture Notes(一)
来源:互联网 发布:莫宁职业生涯数据 编辑:程序博客网 时间:2024/06/05 09:58
多个单核CPU VS 单个多核CPU
每个单核CPU都有独立的电路和cache支持。而多核CPU共享一套芯片组,一套存储,因此,多核之间的通信看起来就变得比多个单核CPU开销要小。但是,数据的共享性又给多核CPU带来了分时开销。
Concurrency:a collection of programs is said to be concurrent if at a given point in time, any of the programs may be the next one to execute its next atomic instruction. It could make better use of resources(time, space etc.)
Shared memory(read and write shared objects in memory), for example:
- A and B might be two threads in the same JAVA program sharing the same JAVA objects
- A and B might be two programs sharing common file
- A and B might be two processors sharing the same physical memory
Message passing(concurrent modules interact by sending message to each other through a communication channel, the messages queue up for handling), for example:
- two hosts communicate by network connections
- web browser and server
- instant messaging client and server
- two programs connect by a pipe
Synchronization:
- mutual exclusion
- condition synchronisation
Process: the execution of a sequential program
Atomic action: a programming instruction which changes a state of a system indivisibly, it can't be interrupted by an instruction from another process
Interleaving: each sequential program is listed in correct order in the interleaving, but the actions of different sequential components can be intermixed
Hardware assumptions:
- read and write from memory(considering the 8-byte long type data situation, things would be different)
- use a variable x, read x from memory and load it into a register, manipulate it inside registers, store the results back in memory
- each process has its private registers and a private stack which are saved when there is a process switch
- shared memory assumption: global variables
y = x + 1
R2 = x
R2 = R2 + 1
y = R2
Reference:
1. The Materials of Concurrent && Distributed Systems Course
- 并发编程基础 Lecture Notes(一)
- 并发编程基础 Lecture Notes(二)
- 并发编程基础 Lecture Notes(三)
- 并发编程基础 Lecture Notes(四)
- Scipy Lecture Notes(一)
- Java并发编程基础(一)
- Java 并发编程 基础 一
- 【Java并发编程】一.基础
- 并发编程一:并发概念和基础
- java并发编程实战 notes
- 《java并发编程实战》基础构建模块(一)
- Go 并发编程基础(一)goroutine,channel
- Java并发编程(1)一基础类和接口
- 深入学习java并发编程:内存模型(一)基础
- java并发编程之线程同步基础(一)
- java并发编程(一基本概念、线程基础)
- 一、Java并发编程基础篇(001)synchronized
- 一、Java并发编程基础篇(003)同步异步
- hibernate操作数据库
- 如何定位Android NDK开发中遇到的错误
- Android LayoutInflater详解
- matlab下将图片序列转化为视频文件
- angularjs---原来犯的低级错误
- 并发编程基础 Lecture Notes(一)
- Xml序列化和反序列化
- Android之 VersionCode,VersionName(1)版本号和版本名称的重要性介绍
- DIV布局的设置(水平或者垂直居中)
- Java-Json解析--01
- JS循环遍历json数据
- mvp模式初探
- git提交代码
- ProgressDialog使用总结