News for hackers. Stuff that matters.
Re:Experiences Building an OS in Rust by Udo on Saturday October 03, 2015 @05:39AM (#10323257)
I was surprised by this as well, so I checked their paper:

"When multiple threads need to share a resource, they can pass ownership through channels. However, as we discuss in the rest of this paper, it does not work well in systems that use non threadbased concurrency models and when resources must be shared [...]

While hardware interrupts are asynchronous, and therefore run concurrently with other kernel code, in our operating system interrupt handlers enqueue tasks to be run in the main scheduler loop, which is single-threaded. As a result, on_receive and send can never run concurrently and no data race is possible. We overcome both issues by declaring most resources as static variables and borrowing them with ’static lifetime. [...]

Being able to mutably borrow static variables multiple times means our operating system can allow multiple drivers to reference hardware resources or each other. However, doing so means we lose the ability to detect real data races at compile time, for example, if the kernel passes a shared resource to an interrupt handler that may run concurrently. Instead, we resort to an overly conservative convention in which interrupt handlers perform no work except posting to the main scheduler’s task queue. An ideal mechanism would, instead, allow for shared state between components that will never run concurrently, but disallow sharing when they may."

Re:Experiences Building an OS in Rust by twic on Saturday October 03, 2015 @07:22AM (#10323475)
> Instead, we resort to an overly conservative convention in which interrupt handlers perform no work except posting to the main scheduler’s task queue

This doesn't seem so bad. OS X does exactly this in order to minimise the time spent in interrupt mode, and so reduce scheduling jitter:

https://developer.apple.com/library/mac/documentation/Darwin...

https://developer.apple.com/library/mac/documentation/Device...

Re:Experiences Building an OS in Rust by cwzwarich on Saturday October 03, 2015 @03:21PM (#10325029)
In reality, IOKit drivers do perform work in the interrupt filter function that actually runs in an interrupt context.
Re:Experiences Building an OS in Rust by acconsta on Saturday October 03, 2015 @03:25PM (#10325047)
I think every OS does this to some extent. Windows uses DPCs, Linux uses tasklets.
Re:Experiences Building an OS in Rust by steveklabnik on Saturday October 03, 2015 @06:45AM (#10323391)
Rust's rules here aren't purely for multithreading, though. For example, even in a single-threaded context, disallowing mutable aliasing prevents things like iterator invalidation.

At the same time, I noticed this paper late last night, and just woke up, so haven't fully let it all sink in yet.

Re:Experiences Building an OS in Rust by vvanders on Saturday October 03, 2015 @11:17AM (#10324174)
Yeah, this seems like the right thing to do in the context of interrupt handlers. You want to get out of them as fast as possible.