Course Description
This course is designed to bring C developers up to speed with a
variety of tools and capabilities of Linux. This includes development
and debugging tools as well as system and library functions. The intent
is to provide background that will be of general interest to all Linux
based developers. Students should be prepared for a some lengthy
programming exercises.
What You Will Learn
1. Linux Development
Objectives and format
Course overview
2. Overview Of Linux Programming
Linux kernel overview
System calls and library routines
Lab Exercises
Use perror()
Examine and use errno.
Experiment with different errors from open()
Trace errors within library functions
3. Programs In Pieces
System Include files
Using and creating libraries
Linking
Using Make
Lab Exercises
Create a new dynamic shared library
Switch the libraries an executable uses via LD_LIBRARY_PATH
Create a Makefile for your library
4. Programming with GNU tools
gcc
optimization
linker
debugging with gdb
Lab Exercises
Compile programs with different optimization options
Examine generated code
Experiment with dead code removal
Use pre-processor macro features
Debug a program after a core dump with GDB
Step through a running program and change variable values on the fly
5. Tools
eclipse
electric fence
valgrind
gprof
gcov
patch
Lab Exercises
Try eclipse
Use gprof to profile a program for performance
Use Electric Fence to look for dynamic memory allocation bugs
Use valgrind to look for dynamically allocated memory bugs
Use cachegrind to examine cache utilization
Use dmalloc to test for memory leaks
Create and use patches
Use source code tools like ctags
6. Process Management
Creating processes
Process signaling and status
Process and user ID's
Lab Exercises
Use the variety of exec() calls
Write a simple shell that forks and execs commands
7. Linux File System
Access Permissions
I/O System Calls
Manipulating files
Higher performance I/O
Lab Exercises
Open/Read/Write with files
Implement “tail -f” like functionality
Use lseek() and mmap()
Do non-blocking I/O with devices
Use select() and poll()
8. Inter-process Communication
Pipes
Semaphores
Message Queues
Sockets
Shared Memory
Lab Exercises
Use pipe()
Use named pipes
Create a socket based server
Create a xinetd based service==========================================================
LESSON 2
Essential Linux Device Driver Development Skills
Course Description
This fast paced course teaches attendees to develop device drivers
for Linux. This course acquaints developers with the issues essential
for Linux device driver development. The course progresses through a
number of topics. Each topic is presented along with a supporting
laboratory exercise before moving on to the next topic. Students
should be prepared for a significant amount of hands-on programming.
What You Will Learn
1. How To Configure And Install The Kernel
The kernel source code
Configure and build a new kernel (Lab Exercise)
Install the new kernel
Lab Exercises
Peruse Linux kernel source code
2. How Loadable Modules Work
Benefits of loadable modules
Use of insmod, modprobe, rmmod, and lsmod
Passing parameters to a module
The GPL and Linux
Lab Exercises
Work with loading and unloading modules
Work with module dependencies
Work with modprobe.conf file
3. Compiling
Identifying important header files
Writing a simple module
Compiling modules
Loading/unloading modules
Exporting symbols from a loadable module
Creating stacked loadable modules
Lab Exercises
Write a loadable kernel module
Use module macros related to the modinfo command
Write a module that uses module parameters
Write a module to avoid word size and endian issues.
4. Tracing and Debugging
printk for debugging
Device information in /proc and /sys
strace to track system calls
ksyms
Debuggers, e.g., gdb, and kgdb
Lab Exercises
Work with controlling printk messages on the console (Lab Exercise)
Create a proc file
Work with an Oops message
Use strace to see driver function results
5. Character Devices
Classes of device files
Major and minor numbers
Creating device files with mknod
Registering character device file
Listing character device driver methods
Dynamic major/minor numbers
Lab Exercises
Examine /proc/devices
Work with device files
Create a skeleton character device driver
Adapt the driver to act differently depending upon the minor number of the device file.
Integrate your driver into a kernel source tree
6. Data: User To/From Kernel
Important functions for accessing user space
Shared Memory
Issues with accessing user space from kernel space
Lab Exercises
Implement a write() function
Implement a read() function
7. I/O ports and interrupts
Uses of I/O ports and IRQs
Platform dependency issues
Functions used for reading and writing I/O ports
Interrupt Handler functions
Restrictions on kernel code running in interrupt context
Lab Exercises
Do IO Port operations inb and outb
Attach an interrupt handler to the mouse and keyboard interrupts
Create a proc file to track interrupts
8. Blocking and Wait Queues
Schedule()
Wait Queues
Safe sleeping
Poll()
Lab Exercises
Mimic named pipe behavior via a driver
Create and use a wait queue
Implement non-blocking
Implement the fsync() function
Implement the poll() function
==========================================================
LESSON 3
Linux Kernel Debugging and Performance
Course Description
This course is designed to train developers in effective debugging
and performance measurement and improvement techniques for the Linux
kernel.
What You Will Learn
1. Linux Kernel Source code and documentation
Browsing the source
LXR
tags
cscope
documentation
Lab Exercises
Find kernel source for various features
Customize kernel source
Determine kernel functionality from source and specialized documentation
2. Kernel Configuration for Debugging and Performance Measurement
spin lock configuration
statistics
lock usage
debug info
mutex
Magic SysRq
KGDB
stack
Memory allocation
Lab Exercises
Create custom kernel configuration for debugging and measurement
Enable a variety of debugging features
Examine features provided by configuration values
Debug spin lock problems
3. Proc Filesystem
Tunable kernel parameters
Creating proc files, sysfs and debugfs
panic, oops, printk, sysrq proc files
printk proc file
sysrq
serial consoles
Lab Exercises
sysctl
create proc file
induce an oops
dmesg
sysrq usage
4. Debugging the kernel
kdb
gdb with /proc/kcore
Debugging with gdb
printk and the console
Deadlocks
Memory leaks
Magic Sysrq
Lab Exercises
Using GDB with the kernel (Lab Exercise)
Detecting and preventing deadlock (Lab Exercise)
Debugging kernel memory leaks (Lab Exercise)
Using the sysrq functionality (Lab Exercise)
KDB (Lab Exercise)
5. Kernel Performance
timing
oprofile
LTT
Lock statistics
sar
Lab Exercises
Using various oprofile features
Using LTT
Examining lock performance and contention
Using sar
6. Kernel Errors
oops
panic
creating dumps
crash
Lab Exercises
Oops messages (Lab Exercise)
Kernel symbol usage (Lab Exercise)
Crash usage (Lab Exercise)----------------------------------------------------------------------------------