SlideShare a Scribd company logo
1 of 33
Case Study: formal verification 
of the Brain Fuck Scheduler 
Abbr. BFS for short, and for reduced profanity in this talk 
Presented by: Mengxuan Xia 
McGill University
August 5th 
2009
August 9th 
2009 
BUT YOU CAN TRY BFS!
Brain Fuck Scheduler (BFS) 
• An alternative to the default Completely Fair Scheduler (CFS) of the 
Linux kernel. 
• Released by Con Kolivas on August 9th 2009 
• Also known for his bitcoin mining software CGMiner
BFS: Pros and Cons 
Pros 
• Outperform CFS of the vanilla 
kernel in almost all benchmarks 
• (Back in 2009) You can compile a 
C program while watching video 
in full screen. 
• Not doable with CFS, the video 
will lag and sound goes out of sync 
Cons 
• Does not scale on processors 
with more than 16 cores. (old 
result)
How BFS and task scheduling works 
(abstracted) 
• Two types of tasks 
• Realtime 
• Quad copter reading data from 
gyroscope and adjust motor speed. 
Must happen in realtime! No need to 
adjust motor speed when it already 
crashed! 
• Normal Photo by Doodybutch
BFS always runs realtime tasks first
How does BFS deal with realtime task? 
O(1) scheduling, in a FIFO pipe.
How does BFS deal with normal task? 
Using a virtual deadline mechanism.
Virtual deadline – how does it work? 
• Each process is assigned with a virtual deadline. 
• The virtual deadline is the time that they can wait in the queue. 
• Virtual deadline determined proportional to NICE level. 
• Deadline is virtual – nothing bad happens if deadline is passed.
How does BFS pick a normal task? 
• If deadline of a process already passed, run it immediately. 
• Otherwise find and run the process with the closest deadline.
It’s time to do verification
Related work in scheduler verification 
• Lone Halkjaer, Karen Haervi, Anna Ingolfsdottir, Verification of the legOS 
Scheduler using Uppaal, Electronic Notes in Theoretical Computer Science, 
Volume 39, Issue 3, 2000, Pages 273-292. 
• Xu Ke; Pettersson, P.; Sierszecki, K.; Angelov, C., "Verification of COMDES-II 
Systems Using UPPAAL with Model Transformation," Embedded and Real- 
Time Computing Systems and Applications, 2008. RTCSA '08. 14th IEEE 
International Conference on , vol., no., pp.153,160, 25-27 Aug. 2008 
• Penix, J.; Visser, W.; Engstrom Verification of time partitioning in the DEOS 
scheduler kernel, E.; Larson, A.; Weininger, N., "," Software Engineering, 
2000. Proceedings of the 2000 International Conference on , vol., no., 
pp.488,497, 2000 (This one uses SPIN)
Why does one want to verify BFS? 
• BFS outperforms the default CFS in benchmark tests with such a 
simple task selection strategy – does this performance gain comes 
with a cost of undesirable side-effects?
What I hoped to verify 
• Fairness of the scheduler 
• Starvation-free
What I hoped to verifyied 
• Fairness of the scheduler 
• Starvation-free
Attempted to use Spin/Promela 
• Did not work 
• No notion of clock in Promela 
• Had to implement a clock and synchronize it with the rest 
• Counter-intuitive 
• Brain-F#!ked
UPPAAL 
• Developed by Uppsala University, 
Sweden and Aalborg University in 
Denmark. 
• A timed-automata verifier 
• With a horrible UI 
• Draw timed-automata 
• Write declarations of the symbols 
used in the system 
• Run it in the simulator 
• Verify the (UPPAAL flavored) LTLs
BFS automata
Process/task 
automata
Suppose we have these processes (all non-realtime 
tasks) 
• Process 0: nice level -1, deadline is current tick + 5 ticks 
• Process 1: nice level 0, deadline is current tick + 10 ticks 
• Process 2: nice level 1, deadline is current tick + 40 ticks 
• Process 3: nice level 0, deadline is current tick + 10 ticks
Verification – All satisfied 
• Starvation-free 
• For all p in processes: infinitely often p in Added state implies that infinitely 
often p in running state 
• Timeout guarantee (a process cannot run infinitely) 
• For all p in processes: p in running state implies eventually p in added state 
• Took over 2 hours to run.
UPPAAL can give us even more 
information 
sup: wait[0] <-> “The least upper bound on process 0’s wait time”
Recall our processes 
• Process 0: nice level -1, deadline is current tick + 5 ticks 
• Process 1: nice level 0, deadline is current tick + 10 ticks 
• Process 2: nice level 1, deadline is current tick + 40 ticks 
• Process 3: nice level 0, deadline is current tick + 10 ticks
What’s the maximum time they will stay 
waiting in the run queue? 
sup: wait[0],wait[1],wait[2],wait[3] 
Verifying formula 11: sup: wait[0],wait[1],wait[2],wait[3] 
-- Formula is satisfied. 
sup{true}: 
wait[0] <= 16 
wait[1] <= 20 
wait[2] <= 51 
wait[3] <= 20
BFS is verifiably starvation-free 
for our set of normal tasks
What about realtime tasks? 
• As soon as you add a realtime task to the system, starvation-free 
property gets violated 
• See for yourself: 
Evil Realtime Process: 
while (true) { 
// I’m going to starve everyone else 
}
But that’s fine 
• Only kernel code or root user can run realtime process 
• Normal desktop users are not affected 
• This explains why bad drivers can freeze your system. Recall the 
spinlock example that Syed gave yesterday.
What to watch out for when modeling a 
timed automata system 
• Don’t attempt to use an integer counter. It will cause exponential 
state space blow up. That’s not how time automata work. 
• Instead, try to solve counting problem by using multiple clocks and 
taking their difference. 
• Subtracting/adding integers to clock values make the system 
undecidable! Find other alternative approaches. 
• Counter-intuitive at first. 
Still counter-intuitive weeks later.
Why I could not verify fairness? 
• A system is fair if every process of the same nice level get to run for 
exactly the same cumulative duration 
• How does one write an LTL formula for that?
Conclusion 
• BFS is verifiably starvation-free for our set of normal tasks 
• Realtime tasks break starvation-free property 
• Easy to modify this UPPAAL diagram to work with any set of tasks 
• Theoretically possible to enumerate all sets of tasks and verify all 
these finite sets of tasks. 
• there can be at most 2^16 processes (on Linux), each with nice value from -20 
to 19)
Future work 
• Fix the horrible UPPAAL tool. 
• Extend this model for multi-core system. [1] 
• Find a way to verify (not necessarily deterministic) fairness. With 
Statistical Model Checking perhaps? [2] 
• Model processes preemption 
[1] Jan Madsen Aske Brekling, Michael R Hansen. Models and formal verification of multiprocessor system-on-chips. 
The journal of Logic and Algebraic Programming, 77(1):1–19, 2008. 
[2] Gerd Behrmann, Kim G. Larsen, and Jacob I. Rasmussen. 2004. Priced timed automata: algorithms and 
applications. In Proceedings of the Third international conference on Formal Methods for Components and 
Objects (FMCO'04), Frank S. Boer, Marcello M. Bonsangue, Susanne Graf, and Willem-Paul Roever (Eds.). 
Springer-Verlag, Berlin, Heidelberg, 162-182.
BFS UPPAAL automata available on Github 
https://github.com/xiamx/bfsverification 
Question?

More Related Content

What's hot

What's hot (17)

Lab: JVM Production Debugging 101
Lab: JVM Production Debugging 101Lab: JVM Production Debugging 101
Lab: JVM Production Debugging 101
 
Optimizing thread performance for a genomics variant caller
Optimizing thread performance for a genomics variant callerOptimizing thread performance for a genomics variant caller
Optimizing thread performance for a genomics variant caller
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Evolution of the Prometheus TSDB (Percona Live Europe 2017)
Evolution of the Prometheus TSDB  (Percona Live Europe 2017)Evolution of the Prometheus TSDB  (Percona Live Europe 2017)
Evolution of the Prometheus TSDB (Percona Live Europe 2017)
 
Redosize
RedosizeRedosize
Redosize
 
Continuous Performance Regression Testing with JfrUnit
Continuous Performance Regression Testing with JfrUnitContinuous Performance Regression Testing with JfrUnit
Continuous Performance Regression Testing with JfrUnit
 
.NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel...
.NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel....NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel...
.NET Core Summer event 2019 in Brno, CZ - War stories from .NET team -- Karel...
 
Prometheus (Monitorama 2016)
Prometheus (Monitorama 2016)Prometheus (Monitorama 2016)
Prometheus (Monitorama 2016)
 
Telemetry indepth
Telemetry indepthTelemetry indepth
Telemetry indepth
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Graduating Flink Streaming - Chicago meetup
Graduating Flink Streaming - Chicago meetupGraduating Flink Streaming - Chicago meetup
Graduating Flink Streaming - Chicago meetup
 
Real time operating systems (rtos) concepts 8
Real time operating systems (rtos) concepts 8Real time operating systems (rtos) concepts 8
Real time operating systems (rtos) concepts 8
 
Distributed Development
Distributed DevelopmentDistributed Development
Distributed Development
 
Migrating to Prometheus: what we learned running it in production
Migrating to Prometheus: what we learned running it in productionMigrating to Prometheus: what we learned running it in production
Migrating to Prometheus: what we learned running it in production
 
Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)Evolution of Monitoring and Prometheus (Dublin 2018)
Evolution of Monitoring and Prometheus (Dublin 2018)
 
Intro to open source telemetry linux con 2016
Intro to open source telemetry   linux con 2016Intro to open source telemetry   linux con 2016
Intro to open source telemetry linux con 2016
 
Prometheus for Monitoring Metrics (Percona Live Europe 2017)
Prometheus for Monitoring Metrics (Percona Live Europe 2017)Prometheus for Monitoring Metrics (Percona Live Europe 2017)
Prometheus for Monitoring Metrics (Percona Live Europe 2017)
 

Viewers also liked

Viewers also liked (9)

Film editing
Film editingFilm editing
Film editing
 
先進網際服務系統1030
先進網際服務系統1030先進網際服務系統1030
先進網際服務系統1030
 
Pbl presentation zhiyi, mario, zoe, justin, ivan
Pbl presentation   zhiyi, mario, zoe, justin, ivanPbl presentation   zhiyi, mario, zoe, justin, ivan
Pbl presentation zhiyi, mario, zoe, justin, ivan
 
先進網際服務系統1008
先進網際服務系統1008先進網際服務系統1008
先進網際服務系統1008
 
Presdiagrama
PresdiagramaPresdiagrama
Presdiagrama
 
Presdiagrama
PresdiagramaPresdiagrama
Presdiagrama
 
TAREA 5
TAREA 5TAREA 5
TAREA 5
 
Art Literacy
Art LiteracyArt Literacy
Art Literacy
 
Lähetyslentäminen
LähetyslentäminenLähetyslentäminen
Lähetyslentäminen
 

Similar to Case study: formal verification of the Brain Fuck Scheduler

In the age of Big Data, what role for Software Engineers?
In the age of Big Data, what role for Software Engineers?In the age of Big Data, what role for Software Engineers?
In the age of Big Data, what role for Software Engineers?
CS, NcState
 
Understand regression testing
Understand regression testingUnderstand regression testing
Understand regression testing
gaoliang641
 

Similar to Case study: formal verification of the Brain Fuck Scheduler (20)

cs1311lecture25wdl.ppt
cs1311lecture25wdl.pptcs1311lecture25wdl.ppt
cs1311lecture25wdl.ppt
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performance
 
L-2 (Computer Performance).ppt
L-2 (Computer Performance).pptL-2 (Computer Performance).ppt
L-2 (Computer Performance).ppt
 
Seven deadly sins of ElasticSearch Benchmarking
Seven deadly sins of ElasticSearch BenchmarkingSeven deadly sins of ElasticSearch Benchmarking
Seven deadly sins of ElasticSearch Benchmarking
 
What to do when detect deadlock
What to do when detect deadlockWhat to do when detect deadlock
What to do when detect deadlock
 
Performance tuning Grails applications
Performance tuning Grails applicationsPerformance tuning Grails applications
Performance tuning Grails applications
 
Lecture1
Lecture1Lecture1
Lecture1
 
MODULE 3 process synchronizationnnn.pptx
MODULE 3 process synchronizationnnn.pptxMODULE 3 process synchronizationnnn.pptx
MODULE 3 process synchronizationnnn.pptx
 
03 performance
03 performance03 performance
03 performance
 
In the age of Big Data, what role for Software Engineers?
In the age of Big Data, what role for Software Engineers?In the age of Big Data, what role for Software Engineers?
In the age of Big Data, what role for Software Engineers?
 
PraveenBOUT++
PraveenBOUT++PraveenBOUT++
PraveenBOUT++
 
Start MPC
Start MPC Start MPC
Start MPC
 
ES3-2020-05 Testing
ES3-2020-05 TestingES3-2020-05 Testing
ES3-2020-05 Testing
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applications
 
Chromatography Data System: Control your Instruments
Chromatography Data System: Control your Instruments Chromatography Data System: Control your Instruments
Chromatography Data System: Control your Instruments
 
Insider operating system
Insider   operating systemInsider   operating system
Insider operating system
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using Jenkins
 
Kubernetes at NU.nl (Kubernetes meetup 2019-09-05)
Kubernetes at NU.nl   (Kubernetes meetup 2019-09-05)Kubernetes at NU.nl   (Kubernetes meetup 2019-09-05)
Kubernetes at NU.nl (Kubernetes meetup 2019-09-05)
 
Kanban - A Crash Course
Kanban - A Crash CourseKanban - A Crash Course
Kanban - A Crash Course
 
Understand regression testing
Understand regression testingUnderstand regression testing
Understand regression testing
 

Recently uploaded

(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
Scintica Instrumentation
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
MohamedFarag457087
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
Silpa
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
seri bangash
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Silpa
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptx
Silpa
 

Recently uploaded (20)

(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
(May 9, 2024) Enhanced Ultrafast Vector Flow Imaging (VFI) Using Multi-Angle ...
 
Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.Selaginella: features, morphology ,anatomy and reproduction.
Selaginella: features, morphology ,anatomy and reproduction.
 
Digital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptxDigital Dentistry.Digital Dentistryvv.pptx
Digital Dentistry.Digital Dentistryvv.pptx
 
Genetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditionsGenetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditions
 
Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdf
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptx
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
module for grade 9 for distance learning
module for grade 9 for distance learningmodule for grade 9 for distance learning
module for grade 9 for distance learning
 
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.Molecular markers- RFLP, RAPD, AFLP, SNP etc.
Molecular markers- RFLP, RAPD, AFLP, SNP etc.
 
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.Cyathodium bryophyte: morphology, anatomy, reproduction etc.
Cyathodium bryophyte: morphology, anatomy, reproduction etc.
 
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
Human & Veterinary Respiratory Physilogy_DR.E.Muralinath_Associate Professor....
 
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort ServiceCall Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdf
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptx
 

Case study: formal verification of the Brain Fuck Scheduler

  • 1. Case Study: formal verification of the Brain Fuck Scheduler Abbr. BFS for short, and for reduced profanity in this talk Presented by: Mengxuan Xia McGill University
  • 3. August 9th 2009 BUT YOU CAN TRY BFS!
  • 4. Brain Fuck Scheduler (BFS) • An alternative to the default Completely Fair Scheduler (CFS) of the Linux kernel. • Released by Con Kolivas on August 9th 2009 • Also known for his bitcoin mining software CGMiner
  • 5. BFS: Pros and Cons Pros • Outperform CFS of the vanilla kernel in almost all benchmarks • (Back in 2009) You can compile a C program while watching video in full screen. • Not doable with CFS, the video will lag and sound goes out of sync Cons • Does not scale on processors with more than 16 cores. (old result)
  • 6. How BFS and task scheduling works (abstracted) • Two types of tasks • Realtime • Quad copter reading data from gyroscope and adjust motor speed. Must happen in realtime! No need to adjust motor speed when it already crashed! • Normal Photo by Doodybutch
  • 7. BFS always runs realtime tasks first
  • 8. How does BFS deal with realtime task? O(1) scheduling, in a FIFO pipe.
  • 9. How does BFS deal with normal task? Using a virtual deadline mechanism.
  • 10. Virtual deadline – how does it work? • Each process is assigned with a virtual deadline. • The virtual deadline is the time that they can wait in the queue. • Virtual deadline determined proportional to NICE level. • Deadline is virtual – nothing bad happens if deadline is passed.
  • 11. How does BFS pick a normal task? • If deadline of a process already passed, run it immediately. • Otherwise find and run the process with the closest deadline.
  • 12. It’s time to do verification
  • 13. Related work in scheduler verification • Lone Halkjaer, Karen Haervi, Anna Ingolfsdottir, Verification of the legOS Scheduler using Uppaal, Electronic Notes in Theoretical Computer Science, Volume 39, Issue 3, 2000, Pages 273-292. • Xu Ke; Pettersson, P.; Sierszecki, K.; Angelov, C., "Verification of COMDES-II Systems Using UPPAAL with Model Transformation," Embedded and Real- Time Computing Systems and Applications, 2008. RTCSA '08. 14th IEEE International Conference on , vol., no., pp.153,160, 25-27 Aug. 2008 • Penix, J.; Visser, W.; Engstrom Verification of time partitioning in the DEOS scheduler kernel, E.; Larson, A.; Weininger, N., "," Software Engineering, 2000. Proceedings of the 2000 International Conference on , vol., no., pp.488,497, 2000 (This one uses SPIN)
  • 14. Why does one want to verify BFS? • BFS outperforms the default CFS in benchmark tests with such a simple task selection strategy – does this performance gain comes with a cost of undesirable side-effects?
  • 15. What I hoped to verify • Fairness of the scheduler • Starvation-free
  • 16. What I hoped to verifyied • Fairness of the scheduler • Starvation-free
  • 17. Attempted to use Spin/Promela • Did not work • No notion of clock in Promela • Had to implement a clock and synchronize it with the rest • Counter-intuitive • Brain-F#!ked
  • 18. UPPAAL • Developed by Uppsala University, Sweden and Aalborg University in Denmark. • A timed-automata verifier • With a horrible UI • Draw timed-automata • Write declarations of the symbols used in the system • Run it in the simulator • Verify the (UPPAAL flavored) LTLs
  • 21. Suppose we have these processes (all non-realtime tasks) • Process 0: nice level -1, deadline is current tick + 5 ticks • Process 1: nice level 0, deadline is current tick + 10 ticks • Process 2: nice level 1, deadline is current tick + 40 ticks • Process 3: nice level 0, deadline is current tick + 10 ticks
  • 22. Verification – All satisfied • Starvation-free • For all p in processes: infinitely often p in Added state implies that infinitely often p in running state • Timeout guarantee (a process cannot run infinitely) • For all p in processes: p in running state implies eventually p in added state • Took over 2 hours to run.
  • 23. UPPAAL can give us even more information sup: wait[0] <-> “The least upper bound on process 0’s wait time”
  • 24. Recall our processes • Process 0: nice level -1, deadline is current tick + 5 ticks • Process 1: nice level 0, deadline is current tick + 10 ticks • Process 2: nice level 1, deadline is current tick + 40 ticks • Process 3: nice level 0, deadline is current tick + 10 ticks
  • 25. What’s the maximum time they will stay waiting in the run queue? sup: wait[0],wait[1],wait[2],wait[3] Verifying formula 11: sup: wait[0],wait[1],wait[2],wait[3] -- Formula is satisfied. sup{true}: wait[0] <= 16 wait[1] <= 20 wait[2] <= 51 wait[3] <= 20
  • 26. BFS is verifiably starvation-free for our set of normal tasks
  • 27. What about realtime tasks? • As soon as you add a realtime task to the system, starvation-free property gets violated • See for yourself: Evil Realtime Process: while (true) { // I’m going to starve everyone else }
  • 28. But that’s fine • Only kernel code or root user can run realtime process • Normal desktop users are not affected • This explains why bad drivers can freeze your system. Recall the spinlock example that Syed gave yesterday.
  • 29. What to watch out for when modeling a timed automata system • Don’t attempt to use an integer counter. It will cause exponential state space blow up. That’s not how time automata work. • Instead, try to solve counting problem by using multiple clocks and taking their difference. • Subtracting/adding integers to clock values make the system undecidable! Find other alternative approaches. • Counter-intuitive at first. Still counter-intuitive weeks later.
  • 30. Why I could not verify fairness? • A system is fair if every process of the same nice level get to run for exactly the same cumulative duration • How does one write an LTL formula for that?
  • 31. Conclusion • BFS is verifiably starvation-free for our set of normal tasks • Realtime tasks break starvation-free property • Easy to modify this UPPAAL diagram to work with any set of tasks • Theoretically possible to enumerate all sets of tasks and verify all these finite sets of tasks. • there can be at most 2^16 processes (on Linux), each with nice value from -20 to 19)
  • 32. Future work • Fix the horrible UPPAAL tool. • Extend this model for multi-core system. [1] • Find a way to verify (not necessarily deterministic) fairness. With Statistical Model Checking perhaps? [2] • Model processes preemption [1] Jan Madsen Aske Brekling, Michael R Hansen. Models and formal verification of multiprocessor system-on-chips. The journal of Logic and Algebraic Programming, 77(1):1–19, 2008. [2] Gerd Behrmann, Kim G. Larsen, and Jacob I. Rasmussen. 2004. Priced timed automata: algorithms and applications. In Proceedings of the Third international conference on Formal Methods for Components and Objects (FMCO'04), Frank S. Boer, Marcello M. Bonsangue, Susanne Graf, and Willem-Paul Roever (Eds.). Springer-Verlag, Berlin, Heidelberg, 162-182.
  • 33. BFS UPPAAL automata available on Github https://github.com/xiamx/bfsverification Question?

Editor's Notes

  1. COMDES-II is a component-based software framework intended for model-integrated development of embedded control systems with hard real-time constraints. It provides various kinds of component models to address critical domain-specific issues, such as real-time concurrency and communication in a timed multitasking environment, modal continuous operation combining reactive control behavior with continuous data processing, etc., by following the principle of separation-of-concerns. In the paper we present a transformational approach to the formal verification of both timing and reactive behaviors of COMDES-II systems using UPPAAL, based on a semantic anchoring methodology. The proposed approach adopts UPPAAL timed automata as the semantic units, to which different behavioral concerns of COMDES-II are anchored, such that a COMDES-II system can be precisely specified in UPPAAL, and verified against a set of desired requirements with the preservation of system original operation semantics.
  2. COMDES-II is a component-based software framework intended for model-integrated development of embedded control systems with hard real-time constraints. It provides various kinds of component models to address critical domain-specific issues, such as real-time concurrency and communication in a timed multitasking environment, modal continuous operation combining reactive control behavior with continuous data processing, etc., by following the principle of separation-of-concerns. In the paper we present a transformational approach to the formal verification of both timing and reactive behaviors of COMDES-II systems using UPPAAL, based on a semantic anchoring methodology. The proposed approach adopts UPPAAL timed automata as the semantic units, to which different behavioral concerns of COMDES-II are anchored, such that a COMDES-II system can be precisely specified in UPPAAL, and verified against a set of desired requirements with the preservation of system original operation semantics.
  3. Fairness does not imply starvation-free. For example. One top priority always run, two equally low priority never run. Fair? yes! Equally low priority tasks get equal share of cpu which is zero. Starvation-free ? no
  4. Make sure to explain what everything means, invariants, transition, guard, synchronization, update
  5. Make sure to explain what everything means, invariants, transition, guard, synchronization, update
  6. Mention why we must specify a set of processes. Make remark that one can replace these processes with the ones related to his objective.
  7. Click to show still counter-intuitive weeks later