[Haskell-cafe] Genuine Need For Persistent Global State?

Don Stewart dons at galois.com
Sat Oct 17 14:15:37 EDT 2009


alangcarter:
> On Fri, Oct 16, 2009 at 9:13 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
> 
>     You don't need anything special for this. A Linux kernel "struct device"
>     has a "void *driver_data" member which is private for your use, and
>     intended for precisely this purpose. Global persistent state makes no more
>     sense for kernel drivers than for most other code: how would it work if you
>     had two mice plugged into your system?
> 
> 
> 
> Thanks Bryan - your thought on this is pure and true :-)
> 
> Although I'm just making a toy driver, I wanted to exercise the bits a real one
> would need, and wrongly thought persistent state would matter. You're quite
> right though - generally, things that matter should go in the per device store,
> which can easily be kmalloc()ed/kfree()ed on open/close, picked up and passed
> into Haskell as a Ptr on write/read (so avoiding even the need to understand
> the C struct in Haskell), then peeked and poked.
> 
> My driver can now accumulate data as I wanted, and I don't feel like I've
> cheated.

So what solution did you pick in the end? Allocate on the C side, and
pass a reference back and forth?

-- Don


More information about the Haskell-Cafe mailing list