kernel driver vs userspace program

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Thu Jan 31 14:12:50 EST 2013


On Thu, 31 Jan 2013 13:38:07 -0500, Simon said:
> Hi guys,
>   I'm building an electrical device which will be controlled by
> computer.  It will have an embedded microcontroller and will use USB
> to communicate with the PC.  I believe this calls automatically for a
> device driver, correct?  And for using the machine from the PC,
> interacting with it, that calls for a userspace program, correct?  I
> mean, doing things differently, such as all in userspace or all
> in-kernel, would be bad form, right?

My *first* reaction would be "do it almost all in userspace and
use libusb to talk to the device from userspace".  Unless there's
weird wonkyness or quirks that have to be handled by a kernel module.

>   My question is in case the machine is used in an industrial context
> where there is really only one usage and one kind of interaction that
> follows a pre-determined procedure (therefore totally automated).

There's no reason that an embedded system can't fire up a /sbin/init
that isn't a standard 'init' but is a program to do the process control
needed - in fact, most no-MMU and many embedded systems do that.

> This could give extremely high priority of execution, I guess.

First, see if you're able to meet the timing constraints from a
regular userspace before worrying about going the RT and/or kernel route.
A lot of embedded controllers are amazingly fast and may not need
any extra assistance to make the timing issues.

> Similar to a factory robot controlled by a computer.  Would it make
> more sense to have everything in kernel space, while the userspace (if
> any) would only serve the purpose of reporting?

Especially in the embedded world, there really isn't one right answer.
You'll have to do some trial-and-error to see what balance of userspace
versus kernel is the proper fit for your application.  But in general,
you want to try to keep it in userspace (where things are more protected
in case of a stray pointer, etc) if at all possible.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130131/087a206b/attachment-0001.bin 


More information about the Kernelnewbies mailing list