CS 326-02 Lecture — Meeting Summary (Fall 2026)¶
- Date: Sep 1, 2026
- Time: 03:11 PM Pacific (US and Canada)
- Meeting ID: 817 1561 3732
- Instructor: Greg
Quick Recap¶
The session delivered an in-depth introduction to Rust programming and its relevance to operating system development:
- Reviewed memory layout (code, heap, stack) and Rust’s safety-focused memory model.
- Covered scalar and compound types (
struct,enum, arrays), their allocation, and usage. - Explained explicit type conversion, overflow handling, and the
OptionandResulttypes. - Introduced ownership, borrowing, and move semantics to prevent common memory errors.
- Included live coding to illustrate concepts.
- Encouraged students to review materials and use AI tools for further exploration.
Next Steps¶
- Students should:
- Clone the in-class repository, run the Rust programs, and review prep materials on ownership, borrowing, move, and copy before Thursday.
- Arrive prepared to work through exercises during Thursday’s class.
- Send questions on Zulip.
Summary¶
Fable 5.1 and Memory Concepts¶
- Introduced Fable 5.1 (a widely available, sophisticated model) and demonstrated using Claude Code to analyze repositories and build context for questions.
- Reviewed memory fundamentals: RAM, code, heap data, and stack data; how processors execute instructions.
- Noted that future kernel work will view memory differently (e.g., hexadecimal addresses and naming conventions), referencing a prior lab section.
RISC-V Memory Architecture Design¶
- Described the RISC-V memory map for the course hardware:
- Physical memory (RAM) begins at a specific base address.
- Lower regions are reserved for I/O devices (e.g., serial driver, disk controller).
- Outlined the kernel’s free-memory strategy:
- Break remaining physical memory into 4 KB pages.
- Track pages on a free list for allocation.
- Emphasized the need to implement a custom allocator (not
malloc/free), requiring someunsafeRust while preserving safety where possible.
Rust Programming Fundamentals Overview¶
- Most development will use safe Rust; kernel work may require
unsafeblocks. - Data types covered:
- Unsigned and signed integers, Booleans, characters, pointer-sized integers (
usize,isize) for addresses, lengths, and indices. - Rust minimizes overhead in data layout on stack/heap compared to languages like Python and Java, which have more hidden indirection and runtime metadata.
Rust Type Conversion Requirements¶
- Rust requires explicit type conversions (unlike C’s implicit casts).
- Overflow handling options:
- Checked operations, wrapping behavior, or saturating to bounds.
- Example files with commentary will be provided for offline review (discussion was cut short in the transcript).
Integer Overflow and Programming Behavior¶
- Reviewed strategies for integer overflow:
- Wrapping, saturating, and checked operations.
- Covered scalar types: Unicode
char,bool, and floating-point numbers. - Demonstrated formatting syntax for printing values.
- Stressed the importance of bitwise operations and hex/binary notation for pointers and device addresses in OS development.
Rust String Formatting and Types¶
- Clarified formatting:
{}uses the Display trait.{:?}uses the Debug trait for types without Display.- Compared memory layout:
- Tuples: fixed elements, possibly heterogeneous, with padding for alignment.
- Arrays: repeated same type, contiguous memory, also subject to padding/alignment.
- Began discussion of
enumtypes (details continued below).
Enum Types in C and Rust¶
- Compared enums:
- C: simple named integer constants.
- Rust: algebraic data types holding variant-specific data.
- Showed pattern matching with
matchto avoid complex if-else chains. - Noted memory sizing:
- Based on the largest variant plus a discriminant (as needed).
- The compiler enforces exhaustive
matchcoverage of all variants.
Rust Data Types and Error Handling¶
- Introduced
Option<T>to replace null references: Some(value)orNone.- Demonstrated:
- Tuples,
structs, mutable variables, safe array operations. - No implicit conversions and prevention of out-of-bounds access (unlike C).
- Used
forwithenumerate()to iterate and safely modify arrays.
Rust Programming Concepts Overview¶
- Worked with
structs,enums, andOption. - Built a queue array of request
enums and usedmatchfor pattern handling. - Applied
Optionto represent absent values or errors. - Took a short break around 4:00 PM due to time constraints.
Rust Data Allocation and Storage¶
- Stack-allocated values: scalars,
structs, arrays, tuples. - Heap-allocated (growable) values:
String,Vec<T>, etc. - Stack holds a small handle (pointer, length, capacity).
- Heap stores the actual buffer.
- Demonstrated vector growth:
- Allocation and reallocation patterns.
- When addresses change and when the allocator can reuse space.
Rust Ownership Rules Overview¶
- Every value has exactly one owner; the owner drops/releases resources when the scope ends.
- Ownership transfers on assignment or when passing to functions (unless borrowing).
- Rust avoids GC and reference counting by default to ensure deterministic memory management.
- Assigned preparation:
- Review the in-class repository.
- Run the Rust programs.
- Read slides/materials on ownership, borrowing, move, and copy.