[openbeos] Re: Add-ons/Module problems/ideas??

  • From: "Alexander G. M. Smith" <agmsmith@xxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Wed, 31 Jul 2002 15:25:08 EDT (-0400)

> This brings up a simple question I was curious about (being a 
> non-driver programmer). What really is the difference between modules 
> and drivers? I know that modules are there to provide common 
> functionality to many drivers, but is that it? Seems like there's 
> something else I'm missing, otherwise why doesn't the kernel treat 
> modules and drivers as the same thing, and let them decide whether 
> they publish devices or export APIs?

Modules are essentially add-ons for kernel code to use.  It's like
a shared memory library, but designed for kernel use (you can't
access them from user land).  They can be automatically unloaded
when nobody is using them.  Plus, they have a version number
system so that the module can tell which version a calling thing
wants and return that API.  The API is just a structure with a
few things (name of the module, flags) plus an array of subroutine
addresses, with the first one being a standard one for init and
uninit and the remainder implement whatever the module is
supposed to do.

So, for the memory pool module, which implements a certain kind
of memory allocator system, just has a table of addresses to its
functions which implement init/uninit, create_pool, delete_pool,
malloc, calloc, realloc and free.  I suppose the uninit function
(called when all users have closed their handle to the module
and the system decides to unload it) will free all memory that
is left allocated.

So, it's just a convenient way to bundle up common code used in
kernel land, plus a simple version system, plus auto unload.

- Alex



Other related posts: