Description
Description
This course provides a deep understanding of programming real-time and multi-core systems on Linux while avoiding common pitfalls. Participants will master concurrency, real-time constraints, and debugging techniques, learning to effectively leverage the primitives offered by modern operating systems.
Through a mix of theoretical lessons and hands-on exercises, trainees will gain practical experience in multi-tasking, synchronization, scheduling, and kernel-level programming in real-time environments.
Training Objectives
- By the end of this course
- participants will:
- Understand real-time multitasking concepts and constraints
- Gain expertise in multi-core processor architectures and hyperthreading
- Master concurrent programming
- On single-core systems
- On multi-core systems
- Learn real-time system constraints such as determinism
- preemption
- and interruptions
- Explore processor architecture features affecting real-time programming
- Cache management
- pipeline optimizations
- and I/O strategies
- Multi-core synchronization and hyperthreading considerations
- Develop skills to debug real-time applications
- Understand the structure of a real-time kernel
- Solve classic concurrency problems (e.g.
- producer-consumer
- dining philosophers)
Course Outline
- Day 1: Introduction to Real-Time & Multi-Core Programming<br />
- Fundamentals of Real-Time Systems<
- Real-time concepts and constraints<
- Multi-tasking and preemptive scheduling<
- Multi-core architectures and hyperthreading<
- Development Environment Setup (Exercise)<
- Install and configure the development and execution environments<
- Create a basic context switch routine<
- Thread-Safe Data Structures<
- Linked lists (single/double)<
- Circular lists, FIFOs, stacks<
- Data integrity verification (assertions, pre/post-conditions)<
- Exercise: Implement a thread-safe doubly linked list<
- Memory Management Strategies<
- Allocation algorithms: Buddy system, best-fit, first-fit, pool management<
- Exercise: Implement a simple thread-safe buddy system memory manager<
- Debugging memory errors (leaks, unallocated access)<
- Exercise: Enhance memory management to detect errors<
- Day 2: Real-Time System Components & Multi-Core Interactions<br />
- Real-Time Task Management<
- Task descriptors, lists, and context switching<
- Scheduling models (fixed priority, RMA, EDF, adaptive scheduling)<
- Exercise: Implement a basic fixed-priority scheduler<
- Interrupt Handling in Real-Time Systems<
- Time and device interrupts<
- Edge vs. level interrupts, vectoring, hardware/software acknowledgment<
- Exercise: Implement a basic interrupt manager<
- Multi-Core System Interactions<
- Cache coherence mechanisms (snooping, MOESI protocol)<
- Memory ordering, barriers, and DMA coherency<
- Exercise: Implement a spinlock for multi-core synchronization<
- Day 3: Multi-Core Scheduling & Synchronization Primitives<br />
- Multi-Core Scheduling<
- Assigning interrupts to processors<
- Optimizing cache usage (avoiding false sharing, cache spilling)<
- Exercise: Study a multi-core scheduler<
- Synchronization Mechanisms<
- Semaphores and mutexes (Exercise: Implement a mutex system)<
- Recursive and non-recursive mutexes (Exercise: Validate proper nesting)<
- Priority Inversion Problem<
- Solutions: Priority Inheritance vs. Priority Ceiling<
- Exercise: Implement priority ceiling for mutexes<
- Condition Variables & Mailboxes (Exercise: Add condition variable support to mutexes)<
- Day 4: Avoiding Sequencing Issues & POSIX Threads<br />
- Common Concurrency Problems & Solutions<
- Producer-consumer, deadlocks, livelocks, starvation<
- Exercise: Solve the dining philosophers problem<
- POSIX Thread Programming (Pthreads)<
- Thread management, mutexes, condition variables<
- Exercise: Solve the readers-writers problem using POSIX threads<
- Thread-local storage (Exercise: Implement per-thread static data storage)<
- POSIX semaphores, scheduling policies (real-time vs. traditional)<
- Day 5: Multi-Tasking in the Linux Kernel & Asymmetric Processing<br />
- Kernel-Level Multi-Tasking<
- Memory management (buddy/slab allocators)<
- Task handling (thread creation, termination)<
- Kernel Synchronization Primitives<
- Atomic operations, spinlocks, read/write locks, semaphores, sequential locks<
- Exercise: Implement a kernel-mode execution barrier<
- Kernel Timing Mechanisms<
- Hardware clocks, software timers, high-resolution timers<
- Exercise: Implement a kernel event synchronization object<
- Asymmetric Multiprocessing (AMP)<
- Architecture, shared memory challenges vs. SMP<
- Inter-Processor Communication (IPC)<
- OpenAMP framework, RemoteProc, rpmsg<
- Exercise: Implement message passing between AMP cores



