[Haskell-cafe] ACIO versus Execution Contexts

Lennart Augustsson lennart at augustsson.net
Tue Nov 30 07:00:00 EST 2004


Keean Schupke wrote:
> Look at how Linux scans the hardware at boot time and initialises
> a driver for each device it finds... that means that each driver is 
> parameterised
> by the IO address of the device, and can be initialised multiple times. 
> When an
> OS boots it runs an initialisation routine (the 'main' of the kernel) 
> This is just
> like the main in a Haskell program - there is no need for anything to be
> initialised _before_ main runs... The init routine calls init on each 
> device
> driver in turn, finally handing control over to the scheduler, which
> loads the 'init' program and that starts all the user programs. I don't 
> see any
> calls for unique guarantees here...

Hear, hear! :)

And to continue on the issue of device IO.  If you look at real,
portable operating systems, the drivers are actually parametrized on
the methods to do IO to the device.  The reason is that different busses
require different ways to do IO (accessing a chip on ISA bus is not the
same as when the chip sits in a USB device).  But you want to reuse the
same driver regardless of the bus, you drivers have to take the device
access methods as arguments.

In all the device drivers I've written there has never been anything
in any driver that makes sure you don't initialize it twice.  On the
contrary.  You need to initialize it once for each device.  It's the
bus driver that makes sure you get one driver per device.  And the
driver on top of the bus driver makes sure you get one bus driver per
bus, etc.
(At the very top there's only one instance (per machine), "mainbus".
Creating one copy of this would be the responsibility of main in
a Haskell OS.)

	-- Lennart


More information about the Haskell-Cafe mailing list