Does a user program always use system calls to access a device driver

drivers

In Linux, does a user program always use system calls to the OS kernel, to access a device driver indirectly?

When the driver is implemented as a module which can be loaded and unloaded, does a user program access the driver directly without making a system call to the kernel?

Best Answer

The user calls library functions that wrap around the system calls (raw syscall is quite rare for a normal programmer). The module code runs in kernel mode anyway, so at some point, there must be a context switch from user space to kernel space. Ideally, most modules will use standardized interfaces (device nodes, netlink sockets, even inet sockets), so that the interaction from the user side will be mostly through read() and write() system calls (ioctl is also quite common, as it covers the "extra" settings that don't fall under standard systemcalls). Buffers will diminish the number of calls, but at the end there's always a system call involved.

Related Question