SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Writing NetBSD Sound Drivers 
in Haskell 
Kiwamu Okabe @ Metasepi Design 
& Takayuki Muranushi @ RIKEN 
AICS
Demo: NetBSD driver in Haskell 
☆ NetBSD audio driver plays sound. 
☆ The driver's interrupt handler 
rewrited using Haskell. 
☆ GC occurs in interrupt handler. 
☆ Watch the movie at following. 
hhhttttttpppsss::://////wwwwwwwww...yyyooouuutttuuubbbeee...cccooommm///wwwaaatttccchhh???vvv===XXXEEEYYYcccRRR555RRRGGG555cccAAA 
☆ This slide: http://bit.ly/ajhc-icfp2014
Demo architecture
Kernel developers want type 
☆ Kernels are developed with C. 
☆ We should design kernel with the 
greatest care. 
☆ C language is unsafe!
Kernel Bug #1: Buffer overrun 
☆ Pointer to array doesn't know the 
length.
Kernel Bug #2: Page fault 
☆ Page fault in user space => SEGV 
☆ Page fault in kernel space => Halt!
Kernel Bug #3: Weak type 
☆ Lots of (void *) and unsafe coercion. 
☆ NetBSD kernel uses it 45130 times! 
$ pwd 
/home/kiwamu/src/netbsd/sys 
$ grep "void *" `find . -name "*.c"` | wc -l 
45130 
☆ Kernel developers frequently use 
(void *) for flexibility. It's realy BAD, but 
there is no other option.
Metasepi Project 
http://metasepi.org/ 
☆ Unix-like OS designed by strong type. 
☆ We want to use Metasepi OS for daily 
desktop usage (e.g. web browser, 
programming, office suite, ... etc.) 
☆ We have surveyed may functional 
languages (e.g. Haskell, OCaml, 
MLton, ... etc.)
Scratch or Rewrite
Snatch-driven development #1 
http://en.wikipedia.org/wiki/Snatcher
Snatch-driven development #2
Why we use jhc ? 
Comparison of programs to print "hoge" 
on terminal. The smaller the values, the 
lesser is the dependency on POSIX, the 
more suitable for system programming.
Unix-like OS needs reentrancy 
☆ Why we need reentrancy? 
☆ Because interrupt handler should be 
reentrant. 
☆ Why we need interrupt handler? 
☆ Because preemptive multitasking 
uses it. 
☆ Why we need the multitasking? 
☆ Because Unix-like OS depends on it.
What's reentrancy ? 
Reentrant code can be interrupted in the middle of its execution 
and then safely called again ("re-entered") before its previous 
invocations complete execution.
How do we get reentrancy in C ? 
☆ C language contexts are isolated.
What's C language Context ?
Problem: Interrupt and GC
Root of the problem 
☆ GHC's Haskell context is global and 
single. 
☆ There is only one GC heap on GHC. 
☆ If interrupt occurs while GC is 
running, the interrupt context can't use 
GC heap, because the running GC is 
paused! 
☆ Therefore GHC's binary isn't 
reentrant.
How we can fix this problem 
We re-define the Haskell Context.
Context-Local Heaps (CLHs) 
☆ Idea: Isolate contexts by local heap
What's Haskell Context on CLHs?
Haskell Context life cycle (CLHs)
Isolated contexts are reentrant?
Benchmark 
(O) Original NetBSD 6.1.2 kernel 
(S) The kernel includes AC'97 and HD Audio driver snatched by Ajhc 
(N) (S) + using naive GC 
(B4) (S) + having GC block 16 Byte 
(B5) (S) + having GC block 32 Byte 
(B6) (S) + having GC block 64 Byte
Thank's for contributors ! 
☆ Music is "signal" created by Epopsan. 
☆ John Meacham as jhc author.
Conclusion 
☆ Can we write Unix in Haskell? 
☆ => Yes! 
☆ How we realize Reentrant GC? 
☆ => With Context-Local Heaps (CLHs)! 
☆ Can we implement CLHs in other 
compilers? 
☆ => Yes! Of course, GHC can do it!

Weitere ähnliche Inhalte

Was ist angesagt?

Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lispfukamachi
 
The art of concurrent programming
The art of concurrent programmingThe art of concurrent programming
The art of concurrent programmingIskren Chernev
 
PHP vs Node.js
PHP vs Node.jsPHP vs Node.js
PHP vs Node.jsSquareboat
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBScyllaDB
 
RBD: What will the future bring? - Jason Dillaman
RBD: What will the future bring? - Jason DillamanRBD: What will the future bring? - Jason Dillaman
RBD: What will the future bring? - Jason DillamanCeph Community
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for JavaCharles Anderson
 
Apache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGIApache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGIWildan Maulana
 
Remote secured storage
Remote secured storageRemote secured storage
Remote secured storageSalo Shp
 
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話なおき きしだ
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02Hiroshi SHIBATA
 
8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)Igalia
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VRISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VScyllaDB
 
Android kotlin coroutines
Android kotlin coroutinesAndroid kotlin coroutines
Android kotlin coroutinesBipin Vayalu
 
Let's make it flow ... one way
Let's make it flow ... one wayLet's make it flow ... one way
Let's make it flow ... one wayRoberto Ciatti
 
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackupPLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackupJervin Real
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.jsNitin Gupta
 
How to Measure Latency
How to Measure LatencyHow to Measure Latency
How to Measure LatencyScyllaDB
 

Was ist angesagt? (20)

Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lisp
 
The art of concurrent programming
The art of concurrent programmingThe art of concurrent programming
The art of concurrent programming
 
PHP vs Node.js
PHP vs Node.jsPHP vs Node.js
PHP vs Node.js
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
RBD: What will the future bring? - Jason Dillaman
RBD: What will the future bring? - Jason DillamanRBD: What will the future bring? - Jason Dillaman
RBD: What will the future bring? - Jason Dillaman
 
what is docker
what is dockerwhat is docker
what is docker
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
Apache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGIApache2 BootCamp : Serving Dynamic Content with CGI
Apache2 BootCamp : Serving Dynamic Content with CGI
 
Remote secured storage
Remote secured storageRemote secured storage
Remote secured storage
 
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話
GraalVMの紹介とTruffleでPHPぽい言語を実装したら爆速だった話
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
 
8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
20140918 ruby kaigi2014
20140918 ruby kaigi201420140918 ruby kaigi2014
20140918 ruby kaigi2014
 
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-VRISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
RISC-V on Edge: Porting EVE and Alpine Linux to RISC-V
 
Android kotlin coroutines
Android kotlin coroutinesAndroid kotlin coroutines
Android kotlin coroutines
 
Let's make it flow ... one way
Let's make it flow ... one wayLet's make it flow ... one way
Let's make it flow ... one way
 
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackupPLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
 
Evented Ruby VS Node.js
Evented Ruby VS Node.jsEvented Ruby VS Node.js
Evented Ruby VS Node.js
 
How to Measure Latency
How to Measure LatencyHow to Measure Latency
How to Measure Latency
 

Ähnlich wie Writing NetBSD Sound Drivers in Haskell

Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programmingKiwamu Okabe
 
Metasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSMetasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSKiwamu Okabe
 
Metasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellKiwamu Okabe
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewKiwamu Okabe
 
Functional MCU programming #0: Development environment
Functional MCU programming #0: Development environmentFunctional MCU programming #0: Development environment
Functional MCU programming #0: Development environmentKiwamu Okabe
 
London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015Chris Fregly
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)Ary Borenszweig
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)Ary Borenszweig
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)Crystal Language
 
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Chris Fregly
 
How to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeHow to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeKiwamu Okabe
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Rebaz Najeeb
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserAndre Weissflog
 
fpga1 - What is.pptx
fpga1 - What is.pptxfpga1 - What is.pptx
fpga1 - What is.pptxssuser0de10a
 
HKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on AnsibleHKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on AnsibleLinaro
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingDynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingHostedbyConfluent
 
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingDynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingYaroslav Tkachenko
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
 

Ähnlich wie Writing NetBSD Sound Drivers in Haskell (20)

Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programming
 
Metasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OSMetasepi team meeting #7: Snatch application on tiny OS
Metasepi team meeting #7: Snatch application on tiny OS
 
Metasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using HaskellMetasepi team meeting #13: NetBSD driver using Haskell
Metasepi team meeting #13: NetBSD driver using Haskell
 
Metasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project OverviewMetasepi team meeting: Ajhc Project Overview
Metasepi team meeting: Ajhc Project Overview
 
Functional MCU programming #0: Development environment
Functional MCU programming #0: Development environmentFunctional MCU programming #0: Development environment
Functional MCU programming #0: Development environment
 
London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
Madrid Spark Big Data Bluemix Meetup - Spark Versus Hadoop @ 100 TB Daytona G...
 
How to rewrite the OS using C by strong type
How to rewrite the OS using C by strong typeHow to rewrite the OS using C by strong type
How to rewrite the OS using C by strong type
 
Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation Lecture 1 Compiler design , computation
Lecture 1 Compiler design , computation
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browser
 
fpga1 - What is.pptx
fpga1 - What is.pptxfpga1 - What is.pptx
fpga1 - What is.pptx
 
HKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on AnsibleHKG18-419 - OpenHPC on Ansible
HKG18-419 - OpenHPC on Ansible
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingDynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
 
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent HashingDynamic Change Data Capture with Flink CDC and Consistent Hashing
Dynamic Change Data Capture with Flink CDC and Consistent Hashing
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Writing NetBSD Sound Drivers in Haskell

  • 1. Writing NetBSD Sound Drivers in Haskell Kiwamu Okabe @ Metasepi Design & Takayuki Muranushi @ RIKEN AICS
  • 2. Demo: NetBSD driver in Haskell ☆ NetBSD audio driver plays sound. ☆ The driver's interrupt handler rewrited using Haskell. ☆ GC occurs in interrupt handler. ☆ Watch the movie at following. hhhttttttpppsss::://////wwwwwwwww...yyyooouuutttuuubbbeee...cccooommm///wwwaaatttccchhh???vvv===XXXEEEYYYcccRRR555RRRGGG555cccAAA ☆ This slide: http://bit.ly/ajhc-icfp2014
  • 4. Kernel developers want type ☆ Kernels are developed with C. ☆ We should design kernel with the greatest care. ☆ C language is unsafe!
  • 5. Kernel Bug #1: Buffer overrun ☆ Pointer to array doesn't know the length.
  • 6. Kernel Bug #2: Page fault ☆ Page fault in user space => SEGV ☆ Page fault in kernel space => Halt!
  • 7. Kernel Bug #3: Weak type ☆ Lots of (void *) and unsafe coercion. ☆ NetBSD kernel uses it 45130 times! $ pwd /home/kiwamu/src/netbsd/sys $ grep "void *" `find . -name "*.c"` | wc -l 45130 ☆ Kernel developers frequently use (void *) for flexibility. It's realy BAD, but there is no other option.
  • 8. Metasepi Project http://metasepi.org/ ☆ Unix-like OS designed by strong type. ☆ We want to use Metasepi OS for daily desktop usage (e.g. web browser, programming, office suite, ... etc.) ☆ We have surveyed may functional languages (e.g. Haskell, OCaml, MLton, ... etc.)
  • 10. Snatch-driven development #1 http://en.wikipedia.org/wiki/Snatcher
  • 12. Why we use jhc ? Comparison of programs to print "hoge" on terminal. The smaller the values, the lesser is the dependency on POSIX, the more suitable for system programming.
  • 13. Unix-like OS needs reentrancy ☆ Why we need reentrancy? ☆ Because interrupt handler should be reentrant. ☆ Why we need interrupt handler? ☆ Because preemptive multitasking uses it. ☆ Why we need the multitasking? ☆ Because Unix-like OS depends on it.
  • 14. What's reentrancy ? Reentrant code can be interrupted in the middle of its execution and then safely called again ("re-entered") before its previous invocations complete execution.
  • 15. How do we get reentrancy in C ? ☆ C language contexts are isolated.
  • 16. What's C language Context ?
  • 18. Root of the problem ☆ GHC's Haskell context is global and single. ☆ There is only one GC heap on GHC. ☆ If interrupt occurs while GC is running, the interrupt context can't use GC heap, because the running GC is paused! ☆ Therefore GHC's binary isn't reentrant.
  • 19. How we can fix this problem We re-define the Haskell Context.
  • 20. Context-Local Heaps (CLHs) ☆ Idea: Isolate contexts by local heap
  • 22. Haskell Context life cycle (CLHs)
  • 23. Isolated contexts are reentrant?
  • 24. Benchmark (O) Original NetBSD 6.1.2 kernel (S) The kernel includes AC'97 and HD Audio driver snatched by Ajhc (N) (S) + using naive GC (B4) (S) + having GC block 16 Byte (B5) (S) + having GC block 32 Byte (B6) (S) + having GC block 64 Byte
  • 25. Thank's for contributors ! ☆ Music is "signal" created by Epopsan. ☆ John Meacham as jhc author.
  • 26. Conclusion ☆ Can we write Unix in Haskell? ☆ => Yes! ☆ How we realize Reentrant GC? ☆ => With Context-Local Heaps (CLHs)! ☆ Can we implement CLHs in other compilers? ☆ => Yes! Of course, GHC can do it!