Linux Kernel Modules

Understanding kernel module management, including loading, unloading, and configuring modules using commands like modprobe, lsmod, and modinfo

Category
Linux
Level
intermediate
Languages
en → en
Cards
51
Markdown
Linux Kernel Modules (.md)

Flashcards (51)

#Front (Term / Question)Back (Definition / Answer)ExampleMultiple-Choice Options
1What is the 'printk' function used for?'printk' is used to print messages to the kernel log, similar to 'printf' in user space.
2What is the purpose of the 'exit' function in a kernel module?The 'exit' function is called when the module is unloaded and is used to clean up resources allocated by the module.
3What is a 'mutex' in kernel programming?A mutex is a synchronization primitive used to protect shared data from concurrent access.
4What is the difference between 'modprobe' and 'insmod'?'modprobe' handles module dependencies and loads modules accordingly, while 'insmod' only loads a specified module without checking dependencies.
5How can you check for module dependencies?You can check for module dependencies using the 'modprobe' command, which automatically resolves dependencies.
6What is a 'kernel thread'?A kernel thread is a thread that runs in kernel space and can perform tasks independently of user space processes.
7How can you check the current kernel version?You can check the current kernel version using the 'uname -r' command.
8What is the significance of the 'MODULE_DESCRIPTION' macro?The 'MODULE_DESCRIPTION' macro provides a human-readable description of the module.
9What is a 'module parameter'?A module parameter is a variable that can be passed to a kernel module at load time to configure its behavior.
10What is a module dependency?A module dependency occurs when one kernel module requires another module to function properly.
11What does the 'free_irq' function do?'free_irq' releases an interrupt line that was previously registered with 'request_irq'.
12What is the purpose of the /lib/modules directory?The /lib/modules directory contains all the kernel modules for the currently running kernel.
13What is the purpose of the 'insmod' command?'insmod' is used to insert a module into the kernel without resolving dependencies.
14What does the 'modprobe -r' command do?'modprobe -r' removes a kernel module and its dependencies from the kernel.
15What is a 'kernel panic'?A kernel panic is a safety measure taken by the operating system when it encounters a fatal error from which it cannot safely recover.
16What does the 'lsmod' command do?'lsmod' lists all currently loaded kernel modules.
17What does the 'modprobe -l' command do?'modprobe -l' lists all available modules that can be loaded.
18What is the purpose of the 'schedule' function?'schedule' is used to yield the processor and allow other processes or threads to run.
19What information does 'modinfo' provide?'modinfo' provides detailed information about a specific kernel module, including its version, author, and parameters.
20What is the purpose of the 'class_create' function?'class_create' is used to create a device class in sysfs for organizing devices.
21What is the 'device_create' function used for?'device_create' is used to create a device node in /dev for a specific device.
22How do you export a symbol from a kernel module?You export a symbol using the 'EXPORT_SYMBOL' macro in the module's code.
23What does 'kfree' do?'kfree' is used to free memory that was previously allocated with 'kmalloc'.
24What is the 'module_param' macro?'module_param' is a macro used to declare module parameters that can be set at load time.
25What command is used to unload a kernel module?The command used to unload a kernel module is 'rmmod' or 'modprobe -r'.
26How can you pass parameters to a kernel module?Parameters can be passed to a kernel module using the 'modprobe' command followed by the module name and parameters, or by specifying them in the module's configuration file.
27What is the purpose of the 'init' function in a kernel module?The 'init' function is called when the module is loaded and is used to initialize the module's resources.
28What is the purpose of the 'Kconfig' file?The 'Kconfig' file is used to define configuration options for kernel modules and their dependencies.
29What is the 'module_init' macro?'module_init' is a macro that specifies the initialization function for a kernel module.
30What is the difference between static and dynamic kernel modules?Static modules are compiled into the kernel at build time, while dynamic modules can be loaded and unloaded at runtime.
31What is the 'dev_t' type?'dev_t' is a data type used to represent device numbers in the Linux kernel.
32What is the purpose of 'kmalloc'?'kmalloc' is used to allocate memory in the kernel space.
33What is the role of the 'Makefile' in kernel module development?The 'Makefile' is used to compile the kernel module and specify build instructions and dependencies.
34What is the significance of the 'MODULE_LICENSE' macro?The 'MODULE_LICENSE' macro specifies the licensing of the module, which can affect its ability to access certain kernel features.
35What is a 'symbol' in the context of kernel modules?A symbol is a function or variable that can be accessed by other modules, allowing for inter-module communication.
36What is the 'udev' daemon?'udev' is a device manager for the Linux kernel that dynamically creates and removes device nodes in /dev.
37What is the 'kernel version'?The kernel version indicates the specific release of the Linux kernel, which can affect module compatibility.
38What is a Linux kernel module?A Linux kernel module is a piece of code that can be loaded into the kernel to extend its functionality without the need to reboot the system.
39What is 'procfs'?'procfs' is a virtual filesystem in Linux that provides an interface to kernel data structures.
40What is the 'cdev' structure?'cdev' is a structure that represents a character device in the Linux kernel.
41What is a 'device driver'?A device driver is a specific type of kernel module that allows the operating system to communicate with hardware devices.
42What is the 'wait_queue' mechanism?The 'wait_queue' mechanism allows processes to sleep and wait for an event to occur, such as data being available.
43What is the role of the 'file_operations' structure?The 'file_operations' structure defines the functions that a device driver must implement to handle file operations.
44What is 'sysfs'?'sysfs' is a virtual filesystem that exposes kernel objects and their attributes to user space.
45What is the 'dmesg' command used for?'dmesg' displays the kernel ring buffer messages, which can include information about module loading and errors.
46What is the purpose of the 'kobject' structure?'kobject' is a structure used to represent kernel objects and manage their lifecycle in sysfs.
47What is the 'module_exit' macro?'module_exit' is a macro that specifies the cleanup function for a kernel module.
48What command is used to load a kernel module?The command used to load a kernel module is 'modprobe' or 'insmod'.
49What is the purpose of the 'request_irq' function?'request_irq' is used to register an interrupt handler for a specific interrupt line.
50What is a 'loadable kernel module'?A loadable kernel module is a module that can be loaded and unloaded from the kernel at runtime.
51What is the purpose of the 'spinlock'?A spinlock is a lightweight synchronization mechanism used to protect critical sections in the kernel.