并发编程基础 Lecture Notes(一)

多个单核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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值