Generation of Concurrency Control Code using Discrete-Event Systems - - PowerPoint PPT Presentation

generation of concurrency control code using discrete
SMART_READER_LITE
LIVE PREVIEW

Generation of Concurrency Control Code using Discrete-Event Systems - - PowerPoint PPT Presentation

Generation of Concurrency Control Code using Discrete-Event Systems Theory Christopher Dragert, Juergen Dingel, Karen Rudie Presented by David Gerhard Motivation Optimal usage of today's Multi-core systems requires parallel executable


slide-1
SLIDE 1

Generation of Concurrency Control Code using Discrete-Event Systems Theory

Christopher Dragert, Juergen Dingel, Karen Rudie

Presented by David Gerhard

slide-2
SLIDE 2

Motivation

  • Optimal usage of today's Multi-core systems

requires parallel executable Software

  • Efficient and correct concurrent source code is

hard to write and debug → facilitate development of concurrent source code

slide-3
SLIDE 3

Introduction

  • Automatic generation of concurrency control

code

  • Input

– Source code without concurrency control – Informal specification of the desired concurrent behaviour

  • Output

– Source code with concurrency controls

slide-4
SLIDE 4

Introduction

  • Aims
  • No Deadlocks
  • No Starvation
  • Minimally restrictive

→ using control theory (Discrete-event System)

slide-5
SLIDE 5

DES - Supervisor-Plant

  • System(Plant) modelled as a finite-state

automaton (FSA)

  • Transitions in FSA are called events

– Events can be controllable or uncontrollable

  • Supervisor modelled as a FSA
  • Enables or disables controllable events

Supervisor Plant Event Control Action

slide-6
SLIDE 6

Process Overview

Uncontrolled Source Code Informal Specification Controlled Source Code

slide-7
SLIDE 7

Process Overview

Uncontrolled Source Code Informal Specification Controlled Source Code Event-Marked Source Code Formal Specification DES Supervisor DES Plant

slide-8
SLIDE 8

Relevant Events

  • Find relevant events for concurrency control
  • Example

– Enter/Exit Critical Section → relevant – Accessing shared variable → non-relevant

  • Mark events in the source code
  • Differentiate controllable and uncontrollable

events

slide-9
SLIDE 9

Example

  • 5 Threads with

dependencies

  • 1 → 2,3,4
  • 5 → 4

1 2 3 4 5

Code example for Thread 3: public void run() { // relevant event: T3-start System.out.println(id); doWork(); }

slide-10
SLIDE 10

DES Plant

  • Build a Finite-state automaton (FSA)

representing all possible event sequences for each Thread

  • Build control-flow graph(CFG) from source code
  • Reduce CFG

– All relevant events remain – All non-relevant events important for CFG structure

remain

slide-11
SLIDE 11

Example

Code example for Thread 3: public void run() { // relevant event: T3-start System.out.println(id); doWork(); }

run() { Sys... doWork 2 } 1 2 2 T3-start T3-start

slide-12
SLIDE 12

Process Overview

Uncontrolled Source Code Informal Specification Controlled Source Code Event-Marked Source Code Formal Specification DES Supervisor DES Plant

slide-13
SLIDE 13

Formal Specification

  • Specifies the allowed subset of event

sequences

  • FSA for each restriction
  • Only restrictive
slide-14
SLIDE 14

Example

1 T1-finish T5-finish T1-finish, T2-start, T3-start, T4-start, T5-finish 1 T5-finish T1-finish, T2-start, T3-start T1-finish, T2-start, T3-start, T4-start, T5-finish 2 2 2 2

slide-15
SLIDE 15

DES Supervisor

  • Only one supervisor (simplification)
  • Different FSA's need to be combined into a

monolithic specification

  • Scalability issue
slide-16
SLIDE 16

Process Overview

Uncontrolled Source Code Informal Specification Controlled Source Code Event-Marked Source Code Formal Specification DES Supervisor DES Plant

slide-17
SLIDE 17

Code Generation

  • Supervisor needs to block non allowed

controllable events

  • Generates a Semaphore for each controllable event

set to the initial state

  • Supervisor state changing function

enables/disables controllable events

slide-18
SLIDE 18

Example – Thread 3

//relevant event: T3start while (true) { if(Synchronizer.stateChangeTest("T3start", Synchronizer.T3start)) break; Synchronizer.T3start.acquireUninterruptibly(); Synchronizer.T3start.release(); }

slide-19
SLIDE 19

Example – Supervisor I

public static synchronized Boolean stateChangeTest(String event, Semaphore eventBlocker) { if (!(eventBlocker == null)) { if (!eventBlocker.tryAcquire()) { return false; } eventBlocker.release(); } changeSupervisorState(event); return true; }

slide-20
SLIDE 20

Example – Supervisor II

private static void changeSupervisorState(String event) { if (event.equals("T1finish")) { switch(Synchronizer.stateTracker) { case(0): Synchronizer.T3start.release(); Synchronizer.T2start.release(); Synchronizer.stateTracker = 1; break; case(1): ...

slide-21
SLIDE 21

Verification

  • Discrete-event theory is proven correct and non

blocking

  • Formal proof for algorithm is still needed
  • Modelchecker (Java Pathfinder)
  • Input not reliable!
slide-22
SLIDE 22

Limitations

  • No dynamic threads generation allowed
  • Monolithic supervisor not very efficient
  • Starvation not properly addressed
slide-23
SLIDE 23

Conclusion

  • DES theory can be applied to concurrency
  • Chosen FSA-based version of DES not

expressive enough

  • Further work needed
slide-24
SLIDE 24

Questions

?