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) | Example | Multiple-Choice Options |
|---|---|---|---|---|
| 1 | What is the 'printk' function used for? | 'printk' is used to print messages to the kernel log, similar to 'printf' in user space. | ||
| 2 | What 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. | ||
| 3 | What is a 'mutex' in kernel programming? | A mutex is a synchronization primitive used to protect shared data from concurrent access. | ||
| 4 | What 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. | ||
| 5 | How can you check for module dependencies? | You can check for module dependencies using the 'modprobe' command, which automatically resolves dependencies. | ||
| 6 | What is a 'kernel thread'? | A kernel thread is a thread that runs in kernel space and can perform tasks independently of user space processes. | ||
| 7 | How can you check the current kernel version? | You can check the current kernel version using the 'uname -r' command. | ||
| 8 | What is the significance of the 'MODULE_DESCRIPTION' macro? | The 'MODULE_DESCRIPTION' macro provides a human-readable description of the module. | ||
| 9 | What 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. | ||
| 10 | What is a module dependency? | A module dependency occurs when one kernel module requires another module to function properly. | ||
| 11 | What does the 'free_irq' function do? | 'free_irq' releases an interrupt line that was previously registered with 'request_irq'. | ||
| 12 | What is the purpose of the /lib/modules directory? | The /lib/modules directory contains all the kernel modules for the currently running kernel. | ||
| 13 | What is the purpose of the 'insmod' command? | 'insmod' is used to insert a module into the kernel without resolving dependencies. | ||
| 14 | What does the 'modprobe -r' command do? | 'modprobe -r' removes a kernel module and its dependencies from the kernel. | ||
| 15 | What 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. | ||
| 16 | What does the 'lsmod' command do? | 'lsmod' lists all currently loaded kernel modules. | ||
| 17 | What does the 'modprobe -l' command do? | 'modprobe -l' lists all available modules that can be loaded. | ||
| 18 | What is the purpose of the 'schedule' function? | 'schedule' is used to yield the processor and allow other processes or threads to run. | ||
| 19 | What information does 'modinfo' provide? | 'modinfo' provides detailed information about a specific kernel module, including its version, author, and parameters. | ||
| 20 | What is the purpose of the 'class_create' function? | 'class_create' is used to create a device class in sysfs for organizing devices. | ||
| 21 | What is the 'device_create' function used for? | 'device_create' is used to create a device node in /dev for a specific device. | ||
| 22 | How do you export a symbol from a kernel module? | You export a symbol using the 'EXPORT_SYMBOL' macro in the module's code. | ||
| 23 | What does 'kfree' do? | 'kfree' is used to free memory that was previously allocated with 'kmalloc'. | ||
| 24 | What is the 'module_param' macro? | 'module_param' is a macro used to declare module parameters that can be set at load time. | ||
| 25 | What command is used to unload a kernel module? | The command used to unload a kernel module is 'rmmod' or 'modprobe -r'. | ||
| 26 | How 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. | ||
| 27 | What 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. | ||
| 28 | What is the purpose of the 'Kconfig' file? | The 'Kconfig' file is used to define configuration options for kernel modules and their dependencies. | ||
| 29 | What is the 'module_init' macro? | 'module_init' is a macro that specifies the initialization function for a kernel module. | ||
| 30 | What 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. | ||
| 31 | What is the 'dev_t' type? | 'dev_t' is a data type used to represent device numbers in the Linux kernel. | ||
| 32 | What is the purpose of 'kmalloc'? | 'kmalloc' is used to allocate memory in the kernel space. | ||
| 33 | What 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. | ||
| 34 | What 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. | ||
| 35 | What 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. | ||
| 36 | What is the 'udev' daemon? | 'udev' is a device manager for the Linux kernel that dynamically creates and removes device nodes in /dev. | ||
| 37 | What is the 'kernel version'? | The kernel version indicates the specific release of the Linux kernel, which can affect module compatibility. | ||
| 38 | What 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. | ||
| 39 | What is 'procfs'? | 'procfs' is a virtual filesystem in Linux that provides an interface to kernel data structures. | ||
| 40 | What is the 'cdev' structure? | 'cdev' is a structure that represents a character device in the Linux kernel. | ||
| 41 | What is a 'device driver'? | A device driver is a specific type of kernel module that allows the operating system to communicate with hardware devices. | ||
| 42 | What 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. | ||
| 43 | What 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. | ||
| 44 | What is 'sysfs'? | 'sysfs' is a virtual filesystem that exposes kernel objects and their attributes to user space. | ||
| 45 | What is the 'dmesg' command used for? | 'dmesg' displays the kernel ring buffer messages, which can include information about module loading and errors. | ||
| 46 | What is the purpose of the 'kobject' structure? | 'kobject' is a structure used to represent kernel objects and manage their lifecycle in sysfs. | ||
| 47 | What is the 'module_exit' macro? | 'module_exit' is a macro that specifies the cleanup function for a kernel module. | ||
| 48 | What command is used to load a kernel module? | The command used to load a kernel module is 'modprobe' or 'insmod'. | ||
| 49 | What is the purpose of the 'request_irq' function? | 'request_irq' is used to register an interrupt handler for a specific interrupt line. | ||
| 50 | What is a 'loadable kernel module'? | A loadable kernel module is a module that can be loaded and unloaded from the kernel at runtime. | ||
| 51 | What is the purpose of the 'spinlock'? | A spinlock is a lightweight synchronization mechanism used to protect critical sections in the kernel. |