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

Move Picker

Move Picker Stats /// The Stats struct stores moves statistics. According to the template parameter /// the class can store History and Countermoves. History records how often /// different moves have been successful or unsuccessful during the current search /// and is used for reduction and move ordering decisions. /// Countermoves store the move that refute a previous one. Entries are stored /// using only the moving piece and destination square, hence two moves with /// different origin but same destination and piece will be considered identical. template<typename T, bool CM = false> struct Stats { static const Value Max = Value(1 << 28); const T* operator[](Piece pc) const { return table[pc]; } T* operator[](Piece pc) { return table[pc]; } void clear() { std::memset(table, 0, sizeof(table)); } void update(Piece pc, Square to, Move m) { table[pc][to] = m; } void update(Piece pc, Square to, Value v) { if (abs(int(v)) >= 324) return; table[pc][to] -= table[pc][to] * abs(int(v)) / (CM ? 936 : 324); table[pc][to] += int(v) * 32; } private: T table[PIECE_NB][SQUARE_NB]; }; typedef Stats<Move> MoveStats; typedef Stats<Value, false> HistoryStats; typedef Stats<Value, true> CounterMoveStats; typedef Stats<CounterMoveStats> CounterMoveHistoryStats; It is a generic 2-D table indexed by (piece, destination square) ...

February 15, 2026 · 32 min

Transposition Tables

Transposition Tables The transposition table is the engine’s memory of previously analyzed positions. Because the same chess position can be reached through different move orders (transpositions), storing results avoids re-searching identical subtrees — this is one of the biggest speedups in modern engines. Stockfish stores a compact 10-byte entry per position. TTEntry — What is stored Each entry stores just enough info to help pruning and move ordering: struct TTEntry { private: friend class TranspositionTable; uint16_t key16; uint16_t move16; int16_t value16; int16_t eval16; uint8_t genBound8; int8_t depth8; }; C++ Used here Structs in C++ In C++, struct and class are almost identical, with one default difference: ...

February 13, 2026 · 20 min