Is a device driver in Linux a program/process or is it just a library?
Clash Royale CLAN TAG#URR8PPP
up vote
20
down vote
favorite
Is a device driver a program that runs on its own, or is it just a library (a group of functions) that is loaded in memory and programs can call one of its functions (so it is not running on its own).
And if it is a program, does it have a process ID, so can I for example terminate a device driver the same way I can terminate any other process?
linux drivers
add a comment |Â
up vote
20
down vote
favorite
Is a device driver a program that runs on its own, or is it just a library (a group of functions) that is loaded in memory and programs can call one of its functions (so it is not running on its own).
And if it is a program, does it have a process ID, so can I for example terminate a device driver the same way I can terminate any other process?
linux drivers
1
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25
add a comment |Â
up vote
20
down vote
favorite
up vote
20
down vote
favorite
Is a device driver a program that runs on its own, or is it just a library (a group of functions) that is loaded in memory and programs can call one of its functions (so it is not running on its own).
And if it is a program, does it have a process ID, so can I for example terminate a device driver the same way I can terminate any other process?
linux drivers
Is a device driver a program that runs on its own, or is it just a library (a group of functions) that is loaded in memory and programs can call one of its functions (so it is not running on its own).
And if it is a program, does it have a process ID, so can I for example terminate a device driver the same way I can terminate any other process?
linux drivers
edited Oct 15 '17 at 19:07
GAD3R
22.7k154895
22.7k154895
asked Oct 15 '17 at 11:02
user255688
1013
1013
1
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25
add a comment |Â
1
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25
1
1
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
32
down vote
On Linux, many device drivers are part of the kernel, not libraries or processes. Programs interact with these using device files (typically in /dev
) and various system calls such as open
, read
, write
, ioctl
...
There are exceptions however. Some device drivers use a mixture of kernel driver stubs and user-space libraries (e.g. using UIO). Others are implemented entirely in user-space, usually on top of some bit-banging interface (UART or GPIO). In both cases, theyâÂÂre generally in-process, so you wonâÂÂt see a separate process, just the process thatâÂÂs using the device.
To âÂÂterminateâ a device driver, youâÂÂd have to stop all the processes using it, then remove its kernel modules (assuming itâÂÂs built as modules), and optionally any other modules it uses and which are no longer necessary. You can list the modules on your system using lsmod
, and unload them using rmmod
or modprobe -r
, both of which will only work if lsmod
indicates they have no users.
2
If you're brave enough, and your kernel was compiled withCONFIG_MODULE_FORCE_UNLOAD
, you can tryrmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.
â Ruslan
Oct 16 '17 at 12:14
add a comment |Â
up vote
8
down vote
You first have to define what a driver is. I'll define it as a program or subroutine that controls a device (like your camera) or a subsystem (like a file system). Whether it does it directly via the system program or via kernel servers or user-land processes shouldn't in principal matter to this essentially semantic question.
In some cases Linux only provides a generic protocol written in software where the actual "driver" is a device tree. That is a configuration of hardware parameters and which software to use that make up a driver.
Generally speaking driver interfaces and protocols are implemented using kernel modules which are loaded as needed defined by device trees or udev rules. A kernel module is not in the strictest sense a process or library.
A library is just a static set of code that can be loaded into any given process. Modern operating systems load these libraries into shared memory. A process can itself link to any number of shared libraries.
A process is a running program in which the system program or kernel has allocated resources such as system memory and cpu time. Kernel modules may or may not follow this pattern themselves but regardless are not regarded as a defacto processes under Linux.
So to answer your question a driver need not be process but it can be. While the code can exist in a library the driver is still loaded into memery via a program whether it be the kernel in the form of kernel modules or userland processes.
It becomes more of a semantic argument when considering what the totality of a driver actually is. You could say a driver is always a program but sometimes its not like in the case of device trees also it could actually be a userland process, device tree file, udev rules and kernel module where the process and module both use libraries all to make up the logic of a driver.
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
32
down vote
On Linux, many device drivers are part of the kernel, not libraries or processes. Programs interact with these using device files (typically in /dev
) and various system calls such as open
, read
, write
, ioctl
...
There are exceptions however. Some device drivers use a mixture of kernel driver stubs and user-space libraries (e.g. using UIO). Others are implemented entirely in user-space, usually on top of some bit-banging interface (UART or GPIO). In both cases, theyâÂÂre generally in-process, so you wonâÂÂt see a separate process, just the process thatâÂÂs using the device.
To âÂÂterminateâ a device driver, youâÂÂd have to stop all the processes using it, then remove its kernel modules (assuming itâÂÂs built as modules), and optionally any other modules it uses and which are no longer necessary. You can list the modules on your system using lsmod
, and unload them using rmmod
or modprobe -r
, both of which will only work if lsmod
indicates they have no users.
2
If you're brave enough, and your kernel was compiled withCONFIG_MODULE_FORCE_UNLOAD
, you can tryrmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.
â Ruslan
Oct 16 '17 at 12:14
add a comment |Â
up vote
32
down vote
On Linux, many device drivers are part of the kernel, not libraries or processes. Programs interact with these using device files (typically in /dev
) and various system calls such as open
, read
, write
, ioctl
...
There are exceptions however. Some device drivers use a mixture of kernel driver stubs and user-space libraries (e.g. using UIO). Others are implemented entirely in user-space, usually on top of some bit-banging interface (UART or GPIO). In both cases, theyâÂÂre generally in-process, so you wonâÂÂt see a separate process, just the process thatâÂÂs using the device.
To âÂÂterminateâ a device driver, youâÂÂd have to stop all the processes using it, then remove its kernel modules (assuming itâÂÂs built as modules), and optionally any other modules it uses and which are no longer necessary. You can list the modules on your system using lsmod
, and unload them using rmmod
or modprobe -r
, both of which will only work if lsmod
indicates they have no users.
2
If you're brave enough, and your kernel was compiled withCONFIG_MODULE_FORCE_UNLOAD
, you can tryrmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.
â Ruslan
Oct 16 '17 at 12:14
add a comment |Â
up vote
32
down vote
up vote
32
down vote
On Linux, many device drivers are part of the kernel, not libraries or processes. Programs interact with these using device files (typically in /dev
) and various system calls such as open
, read
, write
, ioctl
...
There are exceptions however. Some device drivers use a mixture of kernel driver stubs and user-space libraries (e.g. using UIO). Others are implemented entirely in user-space, usually on top of some bit-banging interface (UART or GPIO). In both cases, theyâÂÂre generally in-process, so you wonâÂÂt see a separate process, just the process thatâÂÂs using the device.
To âÂÂterminateâ a device driver, youâÂÂd have to stop all the processes using it, then remove its kernel modules (assuming itâÂÂs built as modules), and optionally any other modules it uses and which are no longer necessary. You can list the modules on your system using lsmod
, and unload them using rmmod
or modprobe -r
, both of which will only work if lsmod
indicates they have no users.
On Linux, many device drivers are part of the kernel, not libraries or processes. Programs interact with these using device files (typically in /dev
) and various system calls such as open
, read
, write
, ioctl
...
There are exceptions however. Some device drivers use a mixture of kernel driver stubs and user-space libraries (e.g. using UIO). Others are implemented entirely in user-space, usually on top of some bit-banging interface (UART or GPIO). In both cases, theyâÂÂre generally in-process, so you wonâÂÂt see a separate process, just the process thatâÂÂs using the device.
To âÂÂterminateâ a device driver, youâÂÂd have to stop all the processes using it, then remove its kernel modules (assuming itâÂÂs built as modules), and optionally any other modules it uses and which are no longer necessary. You can list the modules on your system using lsmod
, and unload them using rmmod
or modprobe -r
, both of which will only work if lsmod
indicates they have no users.
edited Oct 16 '17 at 4:15
answered Oct 15 '17 at 12:22
Stephen Kitt
144k22315379
144k22315379
2
If you're brave enough, and your kernel was compiled withCONFIG_MODULE_FORCE_UNLOAD
, you can tryrmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.
â Ruslan
Oct 16 '17 at 12:14
add a comment |Â
2
If you're brave enough, and your kernel was compiled withCONFIG_MODULE_FORCE_UNLOAD
, you can tryrmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.
â Ruslan
Oct 16 '17 at 12:14
2
2
If you're brave enough, and your kernel was compiled with
CONFIG_MODULE_FORCE_UNLOAD
, you can try rmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.â Ruslan
Oct 16 '17 at 12:14
If you're brave enough, and your kernel was compiled with
CONFIG_MODULE_FORCE_UNLOAD
, you can try rmmod -f
to force unload modules which are in use/not designed to be removed/etc.. This will, apart from simply resulting in a kernel in an unreliable state, also taint the kernel.â Ruslan
Oct 16 '17 at 12:14
add a comment |Â
up vote
8
down vote
You first have to define what a driver is. I'll define it as a program or subroutine that controls a device (like your camera) or a subsystem (like a file system). Whether it does it directly via the system program or via kernel servers or user-land processes shouldn't in principal matter to this essentially semantic question.
In some cases Linux only provides a generic protocol written in software where the actual "driver" is a device tree. That is a configuration of hardware parameters and which software to use that make up a driver.
Generally speaking driver interfaces and protocols are implemented using kernel modules which are loaded as needed defined by device trees or udev rules. A kernel module is not in the strictest sense a process or library.
A library is just a static set of code that can be loaded into any given process. Modern operating systems load these libraries into shared memory. A process can itself link to any number of shared libraries.
A process is a running program in which the system program or kernel has allocated resources such as system memory and cpu time. Kernel modules may or may not follow this pattern themselves but regardless are not regarded as a defacto processes under Linux.
So to answer your question a driver need not be process but it can be. While the code can exist in a library the driver is still loaded into memery via a program whether it be the kernel in the form of kernel modules or userland processes.
It becomes more of a semantic argument when considering what the totality of a driver actually is. You could say a driver is always a program but sometimes its not like in the case of device trees also it could actually be a userland process, device tree file, udev rules and kernel module where the process and module both use libraries all to make up the logic of a driver.
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
add a comment |Â
up vote
8
down vote
You first have to define what a driver is. I'll define it as a program or subroutine that controls a device (like your camera) or a subsystem (like a file system). Whether it does it directly via the system program or via kernel servers or user-land processes shouldn't in principal matter to this essentially semantic question.
In some cases Linux only provides a generic protocol written in software where the actual "driver" is a device tree. That is a configuration of hardware parameters and which software to use that make up a driver.
Generally speaking driver interfaces and protocols are implemented using kernel modules which are loaded as needed defined by device trees or udev rules. A kernel module is not in the strictest sense a process or library.
A library is just a static set of code that can be loaded into any given process. Modern operating systems load these libraries into shared memory. A process can itself link to any number of shared libraries.
A process is a running program in which the system program or kernel has allocated resources such as system memory and cpu time. Kernel modules may or may not follow this pattern themselves but regardless are not regarded as a defacto processes under Linux.
So to answer your question a driver need not be process but it can be. While the code can exist in a library the driver is still loaded into memery via a program whether it be the kernel in the form of kernel modules or userland processes.
It becomes more of a semantic argument when considering what the totality of a driver actually is. You could say a driver is always a program but sometimes its not like in the case of device trees also it could actually be a userland process, device tree file, udev rules and kernel module where the process and module both use libraries all to make up the logic of a driver.
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
add a comment |Â
up vote
8
down vote
up vote
8
down vote
You first have to define what a driver is. I'll define it as a program or subroutine that controls a device (like your camera) or a subsystem (like a file system). Whether it does it directly via the system program or via kernel servers or user-land processes shouldn't in principal matter to this essentially semantic question.
In some cases Linux only provides a generic protocol written in software where the actual "driver" is a device tree. That is a configuration of hardware parameters and which software to use that make up a driver.
Generally speaking driver interfaces and protocols are implemented using kernel modules which are loaded as needed defined by device trees or udev rules. A kernel module is not in the strictest sense a process or library.
A library is just a static set of code that can be loaded into any given process. Modern operating systems load these libraries into shared memory. A process can itself link to any number of shared libraries.
A process is a running program in which the system program or kernel has allocated resources such as system memory and cpu time. Kernel modules may or may not follow this pattern themselves but regardless are not regarded as a defacto processes under Linux.
So to answer your question a driver need not be process but it can be. While the code can exist in a library the driver is still loaded into memery via a program whether it be the kernel in the form of kernel modules or userland processes.
It becomes more of a semantic argument when considering what the totality of a driver actually is. You could say a driver is always a program but sometimes its not like in the case of device trees also it could actually be a userland process, device tree file, udev rules and kernel module where the process and module both use libraries all to make up the logic of a driver.
You first have to define what a driver is. I'll define it as a program or subroutine that controls a device (like your camera) or a subsystem (like a file system). Whether it does it directly via the system program or via kernel servers or user-land processes shouldn't in principal matter to this essentially semantic question.
In some cases Linux only provides a generic protocol written in software where the actual "driver" is a device tree. That is a configuration of hardware parameters and which software to use that make up a driver.
Generally speaking driver interfaces and protocols are implemented using kernel modules which are loaded as needed defined by device trees or udev rules. A kernel module is not in the strictest sense a process or library.
A library is just a static set of code that can be loaded into any given process. Modern operating systems load these libraries into shared memory. A process can itself link to any number of shared libraries.
A process is a running program in which the system program or kernel has allocated resources such as system memory and cpu time. Kernel modules may or may not follow this pattern themselves but regardless are not regarded as a defacto processes under Linux.
So to answer your question a driver need not be process but it can be. While the code can exist in a library the driver is still loaded into memery via a program whether it be the kernel in the form of kernel modules or userland processes.
It becomes more of a semantic argument when considering what the totality of a driver actually is. You could say a driver is always a program but sometimes its not like in the case of device trees also it could actually be a userland process, device tree file, udev rules and kernel module where the process and module both use libraries all to make up the logic of a driver.
edited Oct 16 '17 at 0:48
answered Oct 15 '17 at 13:07
jdwolf
2,392116
2,392116
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
add a comment |Â
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
2
2
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
Minor quibble: kernel modules canâÂÂt be linked to libraries (thatâÂÂs one of the advantages of writing drivers in user-space).
â Stephen Kitt
Oct 15 '17 at 16:11
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398219%2fis-a-device-driver-in-linux-a-program-process-or-is-it-just-a-library%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You can "unload" a driver with rmmod, but only if it's not being used.
â pjc50
Oct 16 '17 at 10:25