1 / 10

CSC 660: Advanced OS

CSC 660: Advanced OS. Kernel Modules. What are Kernel Modules?. Parcels of code that can be dynamically inserted or removed from kernel at run time. Why use Kernel Modules?. Ease of maintenance Compile kernel once. Build, add, and remove modules afterwards. Ease of distribution

Download Presentation

CSC 660: Advanced OS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 660: Advanced OS Kernel Modules CSC 660: Advanced Operating Systems

  2. What are Kernel Modules? Parcels of code that can be dynamically inserted or removed from kernel at run time. CSC 660: Advanced Operating Systems

  3. Why use Kernel Modules? Ease of maintenance Compile kernel once. Build, add, and remove modules afterwards. Ease of distribution Compile single kernel for all machines. Include drivers / options as modules. Vendors can distribute drivers as modules. CSC 660: Advanced Operating Systems

  4. What modules are loaded? > lsmod | head Module Size Used by vmnet 31900 12 vmmon 103584 0 proc_intf 4100 0 freq_table 4100 0 cpufreq_userspace 4572 0 cpufreq_ondemand 6172 0 cpufreq_powersave 1920 0 video 16260 0 sony_acpi 6280 0 > head -3 /proc/modules vmnet 31900 12 - Live 0xf8c3a000 vmmon 103584 0 - Live 0xf8c85000 proc_intf 4100 0 - Live 0xf8c2c000 CSC 660: Advanced Operating Systems

  5. Loading Kernel Modules • modprobe name • Lookup name Resolve aliases using /etc/modprobe.d/* • Check dependencies /lib/modules/version/modules.dep Created by depmod –a • Load prerequisite modules with insmod • Load named module. CSC 660: Advanced Operating Systems

  6. Module Licensing Specified with MOD_LICENSE() macro. If an unlicensed module loaded, kernel tainted: hellomod: module license ‘unspecified’ taints kernel Options found in linux/module.h GPL Dual BSD/GPL Proprietary CSC 660: Advanced Operating Systems

  7. Why Module Licensing? From linux/module.h: • So modinfo can tell users if kernel is free. • So community can ignore bug reports including proprietary modules. • So vendors can do likewise based on their own policies. CSC 660: Advanced Operating Systems

  8. Init and Cleanup Kernel modules must have two functions. init_module Alternatively declare with __init attribute. Ex: register interrupt handler, add system call cleanup_module Alternatively declare with __exit attribute Undoes whatever init_module did so module can be unloaded safely. CSC 660: Advanced Operating Systems

  9. Includes All modules need <linux/module.h> For printk need <linux/kernel.h> Others depending on function. CSC 660: Advanced Operating Systems

  10. References • Daniel P. Bovet and Marco Cesati, Understanding the Linux Kernel, 3rd edition, O’Reilly, 2005. • Robert Love, Linux Kernel Development, 2nd edition, Prentice-Hall, 2005. • Kwan Lowe, Kernel Rebuild Guide, http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html, 2004. • Claudia Rodriguez et al, The Linux Kernel Primer, Prentice-Hall, 2005. • Peter Salzman et. al., Linux Kernel Module Programming Guide, version 2.6.1, 2005. • Andrew S. Tanenbaum, Modern Operating Systems, 2nd edition, Prentice-Hall, 2001. CSC 660: Advanced Operating Systems

More Related