SLIDE 1
Threads, External Processes, Sledgehammer Fabian Immler August 15, - - PowerPoint PPT Presentation
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 2
SLIDE 3
Sledgehammer
- Current goal → External ATP
- In background
- Response: metis commands
SLIDE 4
Demo: sledgehammer
SLIDE 5
Prerequisites
- Isabelle 2009
- PolyML ≥ 5.2.1
SLIDE 6
Threads in ML
- modelled on pthread package
- simplified
SLIDE 7
Threads in Isabelle/ML
- structure SimpleThread
- structure Synchronized
SLIDE 8
Demo: creating Threads
SLIDE 9
Mutual Exclusion
- Mutex ↔ Shared memory
- One lock
- Caution: interaction of lock and interrupt
SLIDE 10
Communication
- Via Shared Memory (eg Mailbox)
- No busy waiting!
- Notification
SLIDE 11
Communication with Condition Variables
- Condition Variable ↔ Mutex
- Wait
- Release Lock
- Condition Variable signal
- Wake up with Lock aquired
SLIDE 12
Demo: pthreads primitives
SLIDE 13
Communication
Example
Sledgehammer:
- global list of active threads
- changes invoke action
SLIDE 14
Common Communication
Begin Lock Signal State? Release Lock Wait Change State Signal Release Lock End no yes wake up
SLIDE 15
Synchronized State Variable
- Global, mutable state
- Synchronized access
- Exclusive locking
- Notification
- Without taking care of mutexes, condition variables, ...
SLIDE 16
Demo: Isabelle/ML combinators
SLIDE 17
Thread Attributes
- Thread is able to modify
- Control delivery of interrupt exceptions
SLIDE 18
Thread Attributes
- EnableBroadcastInterrupt
- InterruptState
- InterruptDefer
- InterruptSynch
- InterruptAsynch
- InterruptAsynchOnce
SLIDE 19
Isabelle/ML combinators
- interruptible
- uninterruptible
- restore attributes inside
SLIDE 20
Demo: Thread attributes
SLIDE 21
system out
- working with threads
- propagation of interrupts
- NOT OS.Process.system
SLIDE 22
system out
- bash Script
- use File.shell path
SLIDE 23
Demo: system out
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
What you need
- SimpleThread.fork
- Thread.broadcastInterrupt :-)
- Synchronized.var
- system out
SLIDE 26