Rust Notes — Module 3

Rust Notes — Module 3: Structs & Enums 1. Structs Structs group related data together into a named type — same concept as C structs, cleaner syntax. struct User { username: String, email: String, age: u32, active: bool, } Creating and Accessing let user = User { username: String::from("sanketh"), email: String::from("sanketh@example.com"), age: 20, active: true, }; println!("{}", user.username); // field access with . Mutability The entire instance must be mut — you cannot mark individual fields as mutable: ...

March 21, 2026 · 7 min

Rust Notes — Module 4

Rust Notes — Module 4: Traits 1. What is a Trait? A trait defines a set of behaviors (methods) that a type must implement. It is a contract — any type that implements the trait promises to provide those behaviors. trait Greet { fn hello(&self) -> String; } Concept Rust C++ Go Trait trait abstract class / concept interface Implementation impl Trait for Type override virtual method implicit (duck typing) Dispatch static (default) or dynamic virtual table interface table 2. Implementing a Trait struct Human { name: String } struct Robot { id: u32 } impl Greet for Human { fn hello(&self) -> String { format!("Hi, I'm {}!", self.name) } } impl Greet for Robot { fn hello(&self) -> String { format!("BEEP. I AM UNIT {}.", self.id) } } Each type provides its own implementation of the trait methods. A type can implement any number of traits. You can implement traits for types you didn’t define (with some restrictions — see orphan rule below). 3. Default Implementations Traits can provide default method implementations. Types can override them or inherit them for free: ...

March 21, 2026 · 8 min

Rust Notes — Module 1

Rust Notes — Module 1: The Basics & Ownership 1. Why Rust? Language Memory Management Cost C Manual (malloc/free) Unsafe — use-after-free, double-free, null deref Go Garbage Collector Safe, but runtime overhead (GC pauses) Rust Ownership system (compiler-enforced) Safe + zero runtime cost Rust’s core promise: memory safety at compile time, with no garbage collector. 2. Variables & Mutability Variables are immutable by default in Rust. You must explicitly opt into mutation with mut. let x = 5; // immutable — cannot be reassigned // x = 6; // ❌ compile error let mut y = 5; // mutable y = 6; // ✅ fine Shadowing You can redeclare a variable with let in the same scope — this is called shadowing: ...

March 17, 2026 · 6 min

Rust Notes — Module 2

Rust Notes — Module 2: Borrowing & References 1. The Problem Ownership Alone Creates If ownership always moves, passing values to functions becomes painful — you lose access to the value after the call: fn print_string(s: String) { println!("{}", s); } // s is dropped here fn main() { let s = String::from("hello"); print_string(s); // println!("{}", s); // ❌ s was moved into print_string, gone! } You’d have to clone everything or return ownership back — both are tedious. Borrowing solves this. ...

March 17, 2026 · 6 min

Lifecycle of a Process

March 8, 2026 · 0 min

Virtualization of the CPU - The Process

Virtualizing the CPU — The Process The Core Idea The OS virtualizes the CPU by running one process, stopping it, running another, and so on. Done fast enough, this creates the illusion that many programs run simultaneously on what might be a single CPU core. The abstraction the OS exposes for this is the Process — simply put, a running program. A program is a lifeless set of instructions sitting on disk. A process is that program, brought to life by the OS. ...

March 3, 2026 · 15 min

Setting up Linux Kernel in Local

Kernel Lab Setup Checklist CVE-2026-31431 (Copy Fail) — Debug Environment This checklist covers everything needed to go from zero to a running kernel inside QEMU with GDB attached and a breakpoint set in the vulnerable function. Follow in order — each step depends on the previous one. Theory: What We’re Building and Why Your Ubuntu laptop ├── QEMU ← virtual machine running your custom kernel │ └── bzImage ← the compiled kernel (compressed, no debug symbols) └── GDB ← debugger attached to QEMU via TCP port 1234 └── vmlinux ← same kernel with full debug symbols (used by GDB only) Why two kernel files? ...

March 1, 2026 · 10 min

Virtualization

Virtualization of CPU What is Virtualization? Virtualization is the OS’s core trick: take a physical resource and transform it into a more general, powerful, and easy-to-use virtual form of itself. Think of it like a hotel. There is one building (physical resource), but every guest gets their own “private” room with its own key, space, and sense of ownership — completely unaware of the others. The hotel management (OS) handles the illusion. ...

March 1, 2026 · 3 min

Principal Variation

Principal Variation The principal variation is the sequence of moves that the engine considers best for both sides from the current position. It’s the “main line” — the path through the game tree that alpha-beta search identifies as optimal. When is Principal Variation Used? After search is complete: The PV is the best line the engine found. This is what gets printed to the GUI — “at depth 12, best line is e4 e5 Nf3…”. Totally useful even without ID, just for knowing the answer. ...

February 21, 2026 · 8 min

Quiescent Search

Quiescent Search The Horizon Effect The horizon effect is when a chess engine makes a terrible move because it can’t see past its search depth limit. It’s like looking at a situation and thinking “This is fine!” when disaster is just one move beyond what you can see. Why Fixed-Depth Search Fails Fixed-depth search stops at a specific depth, regardless of what’s happening in the position. Depth 10 search: ├─ Move 1, 2, 3, ... 10 ✓ Search these └─ Move 11 ✗ STOP (even if critical!) Example 1: The Hanging Queen ...

February 16, 2026 · 19 min