1. Preface
  2. 1. Chapter 1 - Introduction to Systems Programming
    ❱
    1. 1.1. What is systems programming?
    2. 1.2. How to write systems software?
    3. 1.3. Systems programming features in a nutshell
  3. 2. Chapter 2 - The design philosophy of Rust as a systems programming language
    ❱
    1. 2.1. Rust as an ahead-of-time compiled language
    2. 2.2. Rust as a multi-paradigm language
    3. 2.3. Rust as a statically-typed language
    4. 2.4. Rust and ad-hoc polymorphism using traits
    5. 2.5. Rust and the borrow checker
    6. 2.6. Recap
  4. 3. Chapter 3 - The fundamentals of memory management and memory safety
    ❱
    1. 3.1. Types of memory in a typical computer
    2. 3.2. How the operating system manages memory
    3. 3.3. Memory management in Rust - The basics of lifetimes and ownership
      ❱
      1. 3.3.1. The address space of a process
      2. 3.3.2. The Stack
      3. 3.3.3. The Heap
      4. 3.3.4. Memory management basics
      5. 3.3.5. A first glimpse of memory ownership and lifetimes
      6. 3.3.6. Rust and move semantics
      7. 3.3.7. Copying values
      8. 3.3.8. Borrows in Rust
      9. 3.3.9. Mutability and the rule of one
      10. 3.3.10. Summary
    4. 3.4. Smart pointers and reference counting
      ❱
      1. 3.4.1. Slices
      2. 3.4.2. Pointers to single objects in C++
      3. 3.4.3. A Rust smart pointer for single ownership: Box<T>
      4. 3.4.4. Moving beyond single ownership
      5. 3.4.5. A reference-counting smart pointer in Rust: Rc<T>
      6. 3.4.6. Implementing Rc<T> in Rust
      7. 3.4.7. The limits of reference counting
      8. 3.4.8. Summary
    5. 3.5. A first look at unsafe Rust
      ❱
      1. 3.5.1. The motivation for unsafe Rust based on the example of uninitialized memory
      2. 3.5.2. Interfacing with C functions
      3. 3.5.3. A case study on unsafe code using the heapless crate
  5. 4. Chapter 4 - Zero-overhead abstractions - How to write fast, maintainable code
    ❱
    1. 4.1. Product types, sum types, and the Option type
    2. 4.2. Iterators
    3. 4.3. Algorithms
  6. 5. Chapter 5 - Error handling - How to make systems software robust
    ❱
    1. 5.1. Hardware exceptions - How your machine deals with errors
    2. 5.2. Error codes - A simple way to signal errors in code
    3. 5.3. Software exceptions - A more sophisticated error handling mechanism for your code
    4. 5.4. Result<T, E> - Error handling in Rust
  7. 6. Chapter 6 - Systems level I/O - How to make systems talk to each other
    ❱
    1. 6.1. The file abstraction
    2. 6.2. Network communication
    3. 6.3. Interprocess communication using signals and shared memory
    4. 6.4. Command line arguments, environment variables and program exit codes
  8. 7. Chapter 7 - Fearless Concurrency - Using compute resources efficiently
    ❱
    1. 7.1. Threads and synchronization
    2. 7.2. Applied concurrent programming in Rust using the rayon and crossbeam crates
    3. 7.3. Asynchronous programming using async and await
  9. 8. Chapter 8 - Performance
    ❱
    1. 8.1. What is performance, and how do we know that we have it?
    2. 8.2. Understanding performance through benchmarking and profiling

Chapter 3 - The fundamentals of memory management and memory safety

In this chapter, we will start to dive deep into systems programming and will study the hardware resource memory. We will learn how memory is managed, both at the level of the operating system as well as on the level of a systems programming language. In this process, we will learn what tools the Rust programming language provides developers to make best use of memory in their code. Here is the roadmap for this chapter:

  • 3.1. Types of memory in a typical computer
  • 3.2. How the operating system manages memory
  • 3.3. Memory management in Rust - The basics of lifetimes and ownership
    • 3.3.1. The address space of a process
    • 3.3.2. The Stack
    • 3.3.3. The Heap
    • 3.3.4. Memory management basics
    • 3.3.5. A first glimpse of memory ownership and lifetimes
    • 3.3.6. Rust and move semantics
    • 3.3.7. Copying values
    • 3.3.8. Borrows in Rust
    • 3.3.9. Mutability and the rule of one
    • 3.3.10. Summary
  • 3.4. Smart pointers and reference counting
  • 3.5. A first look at unsafe Rust
    • 3.5.1. The motivation for unsafe Rust based on the example of uninitialized memory
    • 3.5.2. Interfacing with C functions
    • 3.5.3. A case study on unsafe code using the heapless crate