Threads, External Processes, Sledgehammer Fabian Immler August 15, - - PowerPoint PPT Presentation

threads external processes sledgehammer
SMART_READER_LITE
LIVE PREVIEW

Threads, External Processes, Sledgehammer Fabian Immler August 15, - - PowerPoint PPT Presentation

Threads, External Processes, Sledgehammer Fabian Immler August 15, 2009 1 Sledgehammer 2 Threads in ML 3 Synchronization pthreads primitives 4 Thread Attributes pthreads primitives Isabelle/ML combinators 5 External Processes 6 End


slide-1
SLIDE 1

Threads, External Processes, Sledgehammer

Fabian Immler August 15, 2009

slide-2
SLIDE 2

1 Sledgehammer 2 Threads in ML 3 Synchronization

pthreads primitives

4 Thread Attributes

pthreads primitives Isabelle/ML combinators

5 External Processes 6 End

slide-3
SLIDE 3

Sledgehammer

  • Current goal → External ATP
  • In background
  • Response: metis commands
slide-4
SLIDE 4

Demo: sledgehammer

slide-5
SLIDE 5

Prerequisites

  • Isabelle 2009
  • PolyML ≥ 5.2.1
slide-6
SLIDE 6

Threads in ML

  • modelled on pthread package
  • simplified
slide-7
SLIDE 7

Threads in Isabelle/ML

  • structure SimpleThread
  • structure Synchronized
slide-8
SLIDE 8

Demo: creating Threads

slide-9
SLIDE 9

Mutual Exclusion

  • Mutex ↔ Shared memory
  • One lock
  • Caution: interaction of lock and interrupt
slide-10
SLIDE 10

Communication

  • Via Shared Memory (eg Mailbox)
  • No busy waiting!
  • Notification
slide-11
SLIDE 11

Communication with Condition Variables

  • Condition Variable ↔ Mutex
  • Wait
  • Release Lock
  • Condition Variable signal
  • Wake up with Lock aquired
slide-12
SLIDE 12

Demo: pthreads primitives

slide-13
SLIDE 13

Communication

Example

Sledgehammer:

  • global list of active threads
  • changes invoke action
slide-14
SLIDE 14

Common Communication

Begin Lock Signal State? Release Lock Wait Change State Signal Release Lock End no yes wake up

slide-15
SLIDE 15

Synchronized State Variable

  • Global, mutable state
  • Synchronized access
  • Exclusive locking
  • Notification
  • Without taking care of mutexes, condition variables, ...
slide-16
SLIDE 16

Demo: Isabelle/ML combinators

slide-17
SLIDE 17

Thread Attributes

  • Thread is able to modify
  • Control delivery of interrupt exceptions
slide-18
SLIDE 18

Thread Attributes

  • EnableBroadcastInterrupt
  • InterruptState
  • InterruptDefer
  • InterruptSynch
  • InterruptAsynch
  • InterruptAsynchOnce
slide-19
SLIDE 19

Isabelle/ML combinators

  • interruptible
  • uninterruptible
  • restore attributes inside
slide-20
SLIDE 20

Demo: Thread attributes

slide-21
SLIDE 21

system out

  • working with threads
  • propagation of interrupts
  • NOT OS.Process.system
slide-22
SLIDE 22

system out

  • bash Script
  • use File.shell path
slide-23
SLIDE 23

Demo: system out

slide-24
SLIDE 24

Further Information

  • PolyML basis (http://www.polyml.org/docs/Threads.html)
  • ˜˜/Pure/Concurrent
  • simple thread.ML
  • synchronized.ML
  • mailbox.ML
  • ˜˜/Pure/ML-Systems/multithreading polyml.ML
  • ˜˜/HOL/Tools/atp manager.ML
slide-25
SLIDE 25

What you need

  • SimpleThread.fork
  • Thread.broadcastInterrupt :-)
  • Synchronized.var
  • system out
slide-26
SLIDE 26

Thank you!