<story><title>P: A programming language for asynchrony, fault-tolerance and uncertainty</title><url>https://www.microsoft.com/en-us/research/blog/p-programming-language-asynchrony/</url></story><parent_chain><item><author>amelius</author><text>Honest question: what is so complicated about writing device drivers, whose sole purpose typically is to transport data from input to output, and vice versa?&lt;p&gt;Also, shouldn&amp;#x27;t drivers be sandboxed to prevent stability problems from affecting the rest of the system?</text></item><item><author>panic</author><text>It&amp;#x27;s worth noting that this isn&amp;#x27;t just a research language -- it&amp;#x27;s used in practice for writing drivers:&lt;p&gt;&lt;i&gt;P got its start in Microsoft software development when it was used to ship the USB 3.0 drivers in Windows 8.1 and Windows Phone. These drivers handle one of the most important peripherals in the Windows ecosystem and run on hundreds of millions of devices today. P enabled the detection and debugging of hundreds of race conditions and Heisenbugs early on in the design of the drivers, and is now extensively used for driver development in Windows.&lt;/i&gt;</text></item></parent_chain><comment><author>tyingq</author><text>&amp;gt;what is so complicated about writing device drivers, whose sole purpose typically is to transport data from input to output, and vice versa&lt;p&gt;I don&amp;#x27;t think it&amp;#x27;s the device driver part that makes it complicated.  It&amp;#x27;s implementing something that is a collection of interdependent state machines in an asynchronous fashion, and doing that in a way that performs well and is reliable and safe.&lt;p&gt;In their specific example of a USB driver, here&amp;#x27;s what&amp;#x27;s in the paper:&lt;p&gt;&lt;i&gt;&amp;quot;It receives a large number of un-coordinated events sent from different sources such as OS, hardware and other drivers, in tricky situations when the system is suspending or powering down. It can receive unexpected events from disabled or stopped devices, noncompliant hardware and buggy drivers. The hub driver can fail requests from incorrect hardware or buggy function drivers. However,it is important that the USB hub itself handles all events and does not crash or hang itself.&amp;quot;&lt;/i&gt;&lt;p&gt;But it doesn&amp;#x27;t have to be a device driver.  They give the example of elevator control in the paper as another collection of state machines that interact.&lt;p&gt;&amp;gt;shouldn&amp;#x27;t drivers be sandboxed to prevent stability problems&lt;p&gt;That would be a microkernel, which has it&amp;#x27;s own set of problems.  There are ways to implement user mode drivers for Windows, Linux, etc, but they are currently limited in functionality and performance.</text></comment>
<story><title>P: A programming language for asynchrony, fault-tolerance and uncertainty</title><url>https://www.microsoft.com/en-us/research/blog/p-programming-language-asynchrony/</url></story><parent_chain><item><author>amelius</author><text>Honest question: what is so complicated about writing device drivers, whose sole purpose typically is to transport data from input to output, and vice versa?&lt;p&gt;Also, shouldn&amp;#x27;t drivers be sandboxed to prevent stability problems from affecting the rest of the system?</text></item><item><author>panic</author><text>It&amp;#x27;s worth noting that this isn&amp;#x27;t just a research language -- it&amp;#x27;s used in practice for writing drivers:&lt;p&gt;&lt;i&gt;P got its start in Microsoft software development when it was used to ship the USB 3.0 drivers in Windows 8.1 and Windows Phone. These drivers handle one of the most important peripherals in the Windows ecosystem and run on hundreds of millions of devices today. P enabled the detection and debugging of hundreds of race conditions and Heisenbugs early on in the design of the drivers, and is now extensively used for driver development in Windows.&lt;/i&gt;</text></item></parent_chain><comment><author>coldtea</author><text>&amp;gt;&lt;i&gt;what is so complicated about writing device drivers, whose sole purpose typically is to transport data from input to output, and vice versa?&lt;/i&gt;&lt;p&gt;What you ask if valid, and very true, but for cable construction, not driver writing.&lt;p&gt;There are tons of protocols and issues to handle when designing a device driver. Negotiate device capabilities. Handle hot plugging and unplugging. Handle intermittent state changes in the device. Handle buffering. Handle different versions of the protocol (or multiple protocols from the same bus). Handle throttling. Initialize and configure the device correctly (and infinite variations of devices from different vendors with perhaps slight or big inconsistencies in their implementation).&lt;p&gt;And of course device drivers are not just about I&amp;#x2F;O.</text></comment>