Salad Asynchronous презентация

Содержание

Слайд 2

Салат асинхронный Салат "Асинхронный": помиогурдоры,цымайон,ез. Salad "Asynchronous": tomacucumtoes,bersmayonn,aise

Салат асинхронный

Салат "Асинхронный": помиогурдоры,цымайон,ез.
Salad "Asynchronous": tomacucumtoes,bersmayonn,aise

Слайд 3

Terminology Concurrency Computation may interleave with other computations Multitasking Device

Terminology

Concurrency
Computation may interleave with other computations
Multitasking
Device may execute more than one

program at a time
Parallel execution
Device is capable of advancing more that one computation in a point of time
Multithreading
Program is represented as a set of worker threads
Asynchrony
Program contain non-blocking calls
Слайд 4

Amdahl law: so we have many CPUs

Amdahl law: so we have many CPUs

Слайд 5

Embarrassingly parallel problems Solved mostly by SIMD

Embarrassingly parallel problems

Solved mostly by SIMD

Слайд 6

Hardware: Atomic operations Load-link/store-conditional Compare-and-swap

Hardware: Atomic operations

Load-link/store-conditional
Compare-and-swap

Слайд 7

Hardware: Fences SFENCE LFENCE MFENCE

Hardware: Fences

SFENCE
LFENCE
MFENCE

Слайд 8

Hardware: Non-uniform memory architecture

Hardware: Non-uniform memory architecture

Слайд 9

Hardware: Hyper Threading

Hardware: Hyper Threading

Слайд 10

Hardware: Intel’s Transactional Synchronization Extensions

Hardware: Intel’s Transactional Synchronization Extensions

Слайд 11

Spinlock\Futex\Crit Section\Fast Mutual Exclusion Context of exclusion Reliable exclusion mechanics

Spinlock\Futex\Crit Section\Fast Mutual Exclusion

Context of exclusion
Reliable exclusion mechanics
Inter-process communication
Waiting time work

(spin\sleep\pump)
Reentrancy
Deadlock detection
Слайд 12

Thread pool pattern

Thread pool pattern

Слайд 13

Reader-writer lock pattern Lock for read (many at a time)

Reader-writer lock pattern

Lock for read (many at a time)
Lock for write

(one at a time, excluding all readers)
Upgradable: escalate from reader to writer
Is sync primitives is really so hard?
.NET 2.0 implementation had a deadlock bug
Starvation is possible
Слайд 14

Event pattern Simple event Autoreset event Countdown event \ rundown protection

Event pattern

Simple event
Autoreset event
Countdown event \ rundown protection

Слайд 15

Semaphore

Semaphore

Слайд 16

Double-checked locking

Double-checked locking

Слайд 17

Striped locking Used in CuncurrentDictionary

Striped locking

Used in CuncurrentDictionary

Слайд 18

Pulse\Wait

Pulse\Wait

Слайд 19

Producer-consumer synchronization

Producer-consumer synchronization

Слайд 20

Futures and promises

Futures and promises

Слайд 21

Futures and promises

Futures and promises

Слайд 22

volatile semantics Non-volatile write Volatile write There is no such

volatile semantics

Non-volatile write

Volatile write

There is no such thing as thread cache.

This is an abstraction over compilers and hardware optimizations.
Source: http://igoro.com/archive/volatile-keyword-in-c-memory-model-explained/
Слайд 23

volatile is not atomic volatile is not atomic volatile is

volatile is not atomic

volatile is not atomic
volatile is not atomic
volatile is

not atomic
volatile is not atomic
volatile is not atomic
volatile is not atomic
volatile is not atomic
volatile is not atomic
Слайд 24

Examples of optimizations prevented by volatile semantics Register allocation Out-of-order

Examples of optimizations prevented by volatile semantics

Register allocation
Out-of-order execution
Loop fusion
Invariant hoisting
Rematerialization
Almost

any compiler, JIT or CPU optimization
https://en.wikipedia.org/wiki/Optimizing_compiler
https://en.wikipedia.org/wiki/Program_optimization
Слайд 25

Memory model Example: .NET memory model Java memory model is

Memory model

Example: .NET memory model

Java memory model is base on “happens

before” memory model
C++ introduced memory model in C++11, most of questions were not even undefined behavior.
There is no such thing as thread cache. This is an abstraction over compilers and hardware optimizations.
Слайд 26

Memory model Search for memory model of your platform\language

Memory model

Search for memory model of your platform\language

Слайд 27

Non-blocking algorithms Obstruction-free Lock-free Wait-free

Non-blocking algorithms

Obstruction-free
Lock-free
Wait-free

Слайд 28

Lock-free stack: Interlocked Singly Linked List Based on work by Alex Skidanov https://habrahabr.ru/post/174369/

Lock-free stack: Interlocked Singly Linked List

Based on work by Alex Skidanov

https://habrahabr.ru/post/174369/
Слайд 29

Lock-free stack: Interlocked Singly Linked List Based on work by

Lock-free stack: Interlocked Singly Linked List

Based on work by Alex Skidanov

https://habrahabr.ru/post/174369/ ? There you’ll find working code

Not lock-free

Undefined behavior

Segfault

ABA

More on lock-free structures and concurrency http://www.1024cores.net/

Слайд 30

Purity\Functionality Source: http://www.slideshare.net/mariofusco/why-we-cannot-ignore-functional-programming

Purity\Functionality

Source: http://www.slideshare.net/mariofusco/why-we-cannot-ignore-functional-programming

Слайд 31

Purity\Functionality

Purity\Functionality

Имя файла: Salad-Asynchronous.pptx
Количество просмотров: 147
Количество скачиваний: 0