Concurrency Algorithms and Theories 03 Operational

Basic operational semantics for concurrency

Basic domains:

Basic domains

Expressions and commands

Programs

P : Tid → \rightarrow Cmd, written as P = c 1 c_1 c1 || … || c N c_N cN

Thread subsystem

  • Thread-local steps: c,s → l \stackrel{l}{\rightarrow} l c’, s’
  • Interpret sequential programs
  • Lift them to program steps: P, S → i : l \stackrel{i:l}{\rightarrow} i:l P’, S’

Storage subsystem (defined by the memory model)

  • Describe the effect of memory accesses and fences
  • M → i : l \stackrel{i : l}{\rightarrow} i:l M’ is the state of storage subsystem

Linking the two

  • Either the thread or the storage subsystem make an internal step, ε \varepsilon ε; or they make matching i : l steps
  • P,S,M ⇒ \Rightarrow P’, S’, M’

The thread subsystem

Store: s : Reg → \rightarrow Val (Initial store: s 0 = △ λ r . 0 s_0 \stackrel{\triangle}{=} \lambda_r.0 s0=λr.0 )

State: <c,s> ∈ \in Command x Store

Transitions:

The thread subsystem: RMW and fence commands

Lifting to concurrent programs

State: ⟨ P , S ⟩ ∈ P r o g r a m × ( T i d → S t o r e ) \langle P, S \rangle \in Program \times (Tid \rightarrow Store) P,SProgram×(TidStore)

  • Initial stores: S 0 = △ λ i . s 0 S_0 \stackrel{\triangle}{=} \lambda_i . s_0 S0=λi.s0
  • Initial state: ⟨ P , S 0 ⟩ \langle P, S_0 \rangle P,S0

Transition:

P ( i ) , S ( i ) → l c , s P , S → i : l P [ i ↦ c ] , S [ i ↦ s ] \dfrac{P(i), S(i) \stackrel{l}{\rightarrow} c,s}{P,S \stackrel{i:l}{\rightarrow} P[i\mapsto c],S[i\mapsto s]} P,Si:lP[ic],S[is]P(i),S(i)lc,s

SC storage subsystem

Machine state: M : Loc → \rightarrow Val

  • Maps each location to its value

  • Initial state: M 0 = △ λ X . 0 M_0 \stackrel{\triangle}{=} \lambda_X . 0 M0=λX.0

    i.e., the memory that maps every location to 0

TSO storage subsystem

The state consists of:

  • A memory M: Loc → \rightarrow Val

  • A function B: Tid → \rightarrow (Loc x Val)*

    assigning a store buffer to every thread.

**Initial state: ** ⟨ M 0 , B 0 ⟩ \langle M_0, B_0 \rangle M0,B0 where

  • M 0 M_0 M0 = λ X . 0 = \lambda_X.0 =λX.0 (the memory maps 0 to every location)
  • B 0 = λ i . ϵ B_0 = \lambda_i.{\epsilon} B0=λi.ϵ (all store buffers are empty)

TSO storage subsystem transitions

TSO: linking thread and storage subsystems

Definition (Allowed outcome)

An outcome O is allowed for a program P under TSO if there exist M such that P P P, S 0 S_0 S0, M 0 M_0 M0, B 0 ⇒ ∗ B_0 \Rightarrow^* B0 skip || … || skip , O , M , B 0 O,M,B_0 O,M,B0

Exercise: PSO storage subsystemd

PSO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值