Csc 660 advanced os
This presentation is the property of its rightful owner.
Sponsored Links
1 / 10

CSC 660: Advanced OS PowerPoint PPT Presentation


  • 70 Views
  • Uploaded on
  • Presentation posted in: General

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Csc 660 advanced os

CSC 660: Advanced OS

Kernel Modules

CSC 660: Advanced Operating Systems


What are kernel modules

What are Kernel Modules?

Parcels of code that can be dynamically inserted or removed from kernel at run time.

CSC 660: Advanced Operating Systems


Why use kernel modules

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


What modules are loaded

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


Loading kernel modules

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


Module licensing

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


Why module licensing

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


Init and cleanup

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


Includes

Includes

All modules need

<linux/module.h>

For printk need

<linux/kernel.h>

Others depending on function.

CSC 660: Advanced Operating Systems


References

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


  • Login