System Programming for Embedded Linux
The performance and stability of a system ultimately depends on how well you use the resources of the underlying operating system. This course focuses on the interface between applications and the Linux kernel and the POSIX specification in particular. Attendees will learn about multi-threaded programming, memory management, signals and interprocess communication, including IPC using local sockets.
It is intended for engineers working on embedded Linux devices, and hence there is an emphasis throughout on robust design, efficient use of resources and real-time behaviour. All lab exercises are cross-compiled and tested on a typical embedded development board. Attendees will learn how to set up the Eclipse IDE for cross development, remote debugging and remote target management.
Dates:
Course Outline
Developing for embedded Linux
- The tool-chain: choosing, installing and testing
- The Linux kernel: customising and cross-compiling
- The bootloader & root file system: final steps to having a working target board
- Embedded development using Eclipse for cross-compiling and remote debug
- Application program interfaces: the POSIX standard
- Open source licenses: GPL/LGPL, BSD, etc.
Files and devices
- Files and file-related API: waiting for several things to happen with select() and poll()
- Devices: everything is a file. Interfacing with a simple device driver. Using the ioctl() function to access device-specific operations
- Interacting with the kernel through /proc & /sys: an example using gpiolib
Processes
- Process life cycle: fork(), exit() & exec()
- Scheduling: real-time & non-real-time policies; setting priority and niceness
Memory
- Virtual memory and its consequences
- Allocating from the heap and stack
- Mapping memory using mmap
Signals
- Standard and real-time signals
- Writing robust signal handlers
- Signal masks and how to handle signals synchronously
Inter-process communication
- Pipes
- Shared memory
- Semaphores
- Messages queues
- Sockets: internet and UNIX (local). Stream and datagram connections
POSIX Threads
- Thread life cycle: pthread_create(), pthread_exit(), pthread_join()
- Scheduling threads: real-time and non-real-time
- The thread stack and how to set the stack size
Thread synchronisation
- Synchronisation using mutexes: priority inversion and priority inheritance
- Condition variables: producer and consumer threads
- Thread cancellation and clean-up operators
- Signals and threads
Time and timers
- Timer accuracy: high-resolution timers, POSIX clocks and timers
- Measuring time
- Periodic tasks
Course Overview
Pre-requisites:
A good understanding of the C language and familiarity with Linux development and command-line tools.
Who Should Attend:
Software engineers and system architects.
Duration:
Four days.
Course Materials:
Printed copies of the presentations and lab notes plus electronic copies of the cross development tools, sample code and worked solutions for the labs.
Related Courses:
Hands-on Labs:
An essential part of the training are the lab sessions, which take approximately 50% of the time. We normally work in pairs using a modern development board such as the Beaglebone. Each group will also need a laptop or desktop to run the system development tools. We will provide a bootable USB memory stick with an appropriate version of Linux and cross tool-chain so there is no need to install Linux beforehand.


