Java thread and lock-5

1 Introduction

2 Synchronization

3 Wait Sets and Notification

4 Sleep and Yield

5 Memory Model

5.1 Shared Variables

5.2 Actions

5.3 Programs and Program Order

5.4 Synchronization Order

5.5 Happens-before Order

5.6 Executions

5.7 Well-Formed Executions

5.8Executions and Causality Requirements

In order to verify the legitimacy of the JVM memory model's constraints on the execution set E = < P, A, po, so, W, V, sw, hb >, the actions in A are submitted in batches during the execution of E , if all the actions of A can be submitted, it means that E conforms to the legal inference of the causal relationship of the memory model of the Java programming language, and its inferred logical relationship conforms to the deduction and induction of mathematical functions and set theory, if and only if:

  • Action set sequence C0, C1..., where C0 is an empty set, Ci is a subset of Ci+1 , A= the union of C0, C1..., if A is a finite set, then C0, C1... are finite, Cn =A, if A is an infinite set, then C0, C1… are infinite, A= the union of C0, C1…

  • The execution sequence E1, ... is legal, where, Ei = < P, Ai, poi, soi, Wi, Vi, swi, hbi >

Given an action set sequence C0, C1... and an execution set sequence E1,..., every action in Ci must be an action in execution set Ei , and all actions in Ci must share Ei and the same corresponding The hb sequence relationship and so relationship of the action, its formal definition is as follows:

1 Ci is a subset of Ai

2 hbi|Ci  =   hb|Ci , which means that within the scope of the action set Ci , the sequence relationship set of hbi is equal to the sequence relationship set of hb

3 soi|Ci = so|Ci , which means that within the scope of the action set Ci , the sequence relationship set of soi is equal to the sequence relationship set of so

The values ​​of all write actions in action set Ci must be the same as the values ​​of all write actions in Ei and E. All read actions in action set Ci must see the values ​​of all write actions in Ei and E. The form is defined as follows Shown:

4 Vi|Ci = V|Ci means that within the scope of the action set Ci , the realization of the Vi function is equivalent to the realization of the V function

5 Wi|Ci-1 = W|Ci-1 , which means that within the scope of the action set Ci , the realization of the Wi function is equivalent to the realization of the W function

All reads in Ei but not in Ci-1 must see all writes that occurred before them, and every read r in Ci-Ci-1 must see all of Ci-1's scopes in Ei and E Write, but you may see different writes in Ei and E , whose formal definition is as follows:

For any read r in Ai – Ci-1, there exists hbi ( Wi(r), r) , indicating that r can see all writes related to r that occurred before r

For any read r in Ci – Ci-1, there exists Wi(r) of scope Ci - 1  and W  ( r) of scope Ci-1  , that is, Wi(r) and W(r) are in Two different writes in the same scope Ci-1

 Given a sufficient sw edge set for Ei , if there is a sw edge set element pair that releases and acquires before the action currently being submitted, then the sw edge set element pair must be in all Ej , where j is greater than or equal to i, Its formal definition is as follows:

Suppose sswi is a swi edge set, which also satisfies the transitivity of hbi sequence relationship set, but does not satisfy po, then sswi is called the sufficient sw edge of Ei , if sswi(x, y) and hb i (y , z) and z is established in Ci , then swj(x, y) is established, where j is greater than or equal to i, it can be seen that if y has been submitted, all external actions that occurred before y have also been submitted

9   Suppose y is in Ci , x is an external action and hbi(x, y) , then x is in Ci

(to be continued)

Guess you like

Origin blog.csdn.net/uesowys/article/details/129538650