Table of Contents

Praktikum „Kernel Programming“

Description

Since the early age of computers operating systems (OS) have been playing a vital role in the software stack. The operating system is a software layer at the bottom of the software stack that extracts a high level abstraction of the underlying hardware, implements resource management and offers a variety of services into the layers that sit on top of it. Although programs can run directly on top of the hardware this is a rare case that usually can been seen only in embedded systems. Programming exactly above the “bare metal” machine adds more complexity to the programmers and requires a better understanding of the hardware.

The modern operating systems consist of a program so called kernel. The main functionality of the kernel is to handle the Central Processing Unit (CPU), the memory accesses and the input/output (I/O) requests. The software that is implemented as part of the kernel run in the context so called kernel space whereas the software on top of it in the so called user space. This comes from the memory abstraction that the kernel provides to applications (in this context applications can be considered the software implemented on top of the kernel). Running in the kernel space gives programmers privileged access to the hardware that in many cases is restricted from the user space, thus several functionalities can be implemented only inside the kernel space. Moreover, since the kernel is at the bottom of the software stack, it can dramatically affect the performance of the applications in many cases.

Currently, one of the most widely used operating systems (especially in the server environments) is the Linux OS, that consist of the Linux kernel. The Linux kernel, initially written from Linus Torvalds, follows the principles found in the Unix-kernel and it is published under the GNU General Public License version 2 (GPLv2). In this software lab you will learn the basics for Linux kernel development. At the end of this course you should be able to write your own kernel module.

This software lab will be given in English.

Target audience

This software lab is suitable for advance undergraduate and graduate students of the Computer Science department. It requires advanced knowledge C programming language. Moreover, familiarity with basic Linux (Unix) utilities such as ls, rm, grep, tar. Use of available text editors (e.g, Vim, emacs.). Experience with any major Linux distribution. Students of other departments are also welcome.

Date and Time

Time Wednesday, 12:15–14:00 Uhr
Place DKRZ, Raum 207
Stats 15 Okt. 2014
Ends 28 Jan. 2014
Mailing list KP-1415

Lecturers

Overview

In the first weeks of the lectures we will recap all the required knowledge for this software lab. Then we will introduce the basic concepts and principles of Linux Kernel programming. Later, the participants will have to present specific aspects of Linux Kernel programming. Short assignments will be given to students during the semester. At the end of the semester the students will also have to work on a short project.

Syllabus

Presentations given by the lecturers:

– Above presentations are licensed under the Creative Commons Attribution 4.0 International License.

Presentations given by the students*:

* two hours per presentation.

Rules for the presentations

  1. At least three weeks prior the date of the presentation, you should send your supervisor a list of bullet points (related to your topic) that you will include in your presentation.
  2. Two weeks before the date of the presentation, you should send a draft of the slides of the presentation.
  3. One week before the date of the presentation, you should send an advanced/final version of the slides of the presentation.
  4. If we do not receive your slides 1 week prior the date of the presentation or in case of no show, your time slot will be cancelled and, therefore, you will fail.

You are advised to have face to face meetings with your supervisor in the beginning/meantime if you need help or solve questions. To do so, arrange in advance an appointment with your corresponding supervisor.

Code examples

Assignments

It is recommended to use a virtual machine to solve your assignments since you can easily crash your system. However, compiling the kernel will take considerably longer. You are free to choose whichever virtualization solution you prefer (https://www.linux-kvm.org, https://www.virtualbox.org, https://www.vmware.com). Use CentOS 7.0 http://www.centos.org.

Policies

References

https://www.kernel.org/

http://lxr.linux.no/

http://lxr.free-electrons.com/

http://lse.sourceforge.net/kdump/

http://www.crashcourse.ca/introduction-linux-kernel-programming/introduction-linux-kernel-programming

http://lttng.org/docs/#doc-instrumenting-linux-kernel

https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x490.html

http://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf

http://www.centos.org/

https://help.ubuntu.com/

http://www.tldp.org/

Memory layout: http://mylinuxbook.com/linux-processes-part2/

Virtual memory in Linux (kernel): http://www.makelinux.net/ldd3/chp-15-sect-1

Programming in General

C-Workshop / Tutorial: http://wr.informatik.uni-hamburg.de/_media/teaching/wintersemester_2011_2012/c-workshop.zip

Git-Workshop: http://wr.informatik.uni-hamburg.de/teaching/wintersemester_2011_2012/git-workshop

Git-Cheat-Sheet: https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf

Shell-Programming Bash-Intorduction: https://help.ubuntu.com/community/Beginners/BashScripting http://wiki.ubuntuusers.de/Shell/Bash-Skripting-Guide_f%C3%BCr_Anf%C3%A4nger

Linux Cheat-Sheet: http://www.computerworld.com/article/2598082/linux/linux-command-line-cheat-sheet.html

Makefile tutorial: http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ GNU Make Manual: http://www.gnu.org/software/make/manual/make.html

Debugging

Kernel debugger

"Memory" debugger

Debugfs

Debugfs TUTORIAL!

KProbes

Kprobes / Systemtap

Systemtap in Ubuntu

Books

  1. Linux Device Drivers, 3d edition, Sprache: Englisch, ISBN-10: 0596005903, ISBN-13: 978-0596005900, price: EUR 29,00
  2. Linux Kernel Development (3rd Edition), Sprache: Englisch, ASIN: B003V4ATI0, price: EUR 30,95
  3. Advanced Programming in the UNIX Environment, Second Edition, Sprache: Englisch, ISBN-10: 0321637739, ISBN-13: 978-0321637734, price: EUR 44,95
  4. Understanding the Linux Kernel, 3rd edition, Sprache: Englisch, ASIN: B00E28C248, price: EUR 73,00
  5. Essential Linux Device Drivers (Prentice Hall Open Source Software Development), Sprache: Englisch, ISBN-10: 132396556, ISBN-13: 978-0132396554, price: 36,95
  6. Modern Operating Systems (3rd Edition), Publisher: Prentice Hall; 3 edition (December 21, 2007), Language: English, ISBN-10: 0136006639, ISBN-13: 978-0136006633
  7. Linux Performance and Tuning Guidelines, An IBM Redpaper publication http://www.redbooks.ibm.com/abstracts/redp4285.html
  8. The C Programming Language, 2nd Edition, Publisher: Prentice Hall; 2 edition (April 1, 1988), Language: English, ISBN-10: 0131103628, ISBN-13: 978-0131103627
  9. Modern Operating Systems, 3rd Edition, Author: Andrew S. Tanenbaum, Sprache: Englisch, ISBN-10: 1292025778, ISBN-13: 978-1292025773
  10. Just for Fun: The Story of an Accidental Revolutionary, Publisher: HarperBusiness; Reprint edition (June 4, 2002), Language: English, ISBN-10: 0066620732, ISBN-13: 978-0066620732
1)
Konstantinos Chasapis
2)
Julian Kunkel
3)
Marc Wiedemann
4)
Manuel Dolz