5102 - Foundations of Comp Sys
← 5102 - Foundations of Comp Sys
session: "5102-foundations-of-comp-sys/2026-09-13 0000 FCS 13 Sep"
title: "FCS 13 Sep"
date: "2026-09-13 00:00"
duration: "2h 56m"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 5
transcript_chars: 113836
generated: "2026-11-23T15:27:00+05:30"
This class introduced the CPU as the central hardware component for program execution. It covered the physical structure of a CPU, including cores, caches (L1, L2, L3), and internal units like the control unit, ALU, and registers. The session traced the flow of a simple program (adding two integers) from secondary storage through RAM, CPU caches, registers, and the ALU, highlighting the roles of different components. It also distinguished between compiled and interpreted languages at the decode level, explained the storage hierarchy, and introduced the four-phase instruction cycle (fetch, decode, execute, write-back). This lecture establishes the foundational hardware context for understanding how machine code is executed.
The CPU is a palm-sized chip containing multiple processing cores, a cache hierarchy, and specialized units. Cores are individual processing units. The control unit manages instruction flow and decoding but does not handle data. The ALU (Arithmetic Logic Unit) and FPU are execution units that perform calculations. Registers (e.g., R1, R2) are very fast, small storage locations inside the core for holding operands and immediate results. This structure matters because it defines the hardware environment where all software ultimately runs.
A ranking of storage types by speed and capacity: Registers (fastest, smallest, inside CPU core), Cache (L1/L2 per core, L3 shared, faster than RAM), Main Memory (RAM) (directly accessible, larger, slower), and Secondary Storage (HDD/SSD, permanent, slowest). This hierarchy is crucial for performance; the CPU tries to keep frequently used data in the fastest storage levels.
L1 cache is the fastest and smallest, split into instruction (L1I) and data (L1D) caches, one per core. L2 cache is larger and slower, also one per core, acting as a queue for instructions before they are split for L1. L3 cache is shared by all cores and used for storage/swapping when registers are full or for inter-core communication, not for incoming instructions. Caches temporarily hold data and instructions to bridge the speed gap between the CPU and RAM.
The basic cycle a CPU follows to process each instruction: Fetch (read instruction from memory into IR, increment PC), Decode (control unit interprets the instruction), Execute (operation performed in a unit like the ALU), and Write-back (result stored to a register or memory). This cycle is fundamental to understanding how a sequence of machine code commands is carried out.
Compiled programs (e.g., EXE, JAR) are already decoded into assembly language, so the CPU only needs to convert assembly to machine language (binary). Interpreted languages require the CPU to decode at two levels (high-level language to assembly, then assembly to machine), making them slower. This distinction highlights the relationship between software abstraction and hardware execution time.
A 32-bit CPU can process up to 32 bits in one operation. It can run a 16-bit OS (underutilized) but cannot fully support a 64-bit OS; processing will be limited to 32 bits. The OS bit-width (e.g., 64-bit) is often wider to handle complex communication with memory and devices, while the CPU's primary processing may still use 32-bit instructions.
Not covered in this session.
1. Program stored on secondary storage (HDD/SSD).
2. User inputs 10 and 25 via keyboard (I/O controller).
3. Input transferred to RAM. RAM creates instructions and allocates variables.
4. Memory controller takes instructions/data to CPU.
5. Control unit fetches and controls flow; instruction decoder decodes to machine language.
6. Data moved to CPU registers: e.g., R1=10, R2=25.
7. ALU executes addition: 10 + 25 = 35.
8. Result stored in register R3=35.
9. Result can be sent back to RAM or hard disk.
10. Result output to user via I/O controller to screen.
Cache behavior: After operation, R1 and R2 are released; result (35) may be cached (L3 cache mentioned for infrequent reuse).
A common 32-bit instruction format was described:
000000 for ADD.add R1, R2, R3, the machine code representation places the result register (R3) first after the opcode, then the source registers. The control unit decodes this.A simple calculator operation (25 + 30) translates to a minimum of 5 CPU instructions (e.g., load R1, load R2, add, store result, display).
Q: What is the role of L1 and L2 cache between RAM and CPU registers?
A: L1 cache holds the instruction and the data to feed the core. L2 cache acts as a queue, especially important for multi-processing/multi-cache scenarios.
Q: What is the role of the flag?
A: After computation completes, a flag in the status register is updated with the operation's status (completed, stuck, etc.) to communicate to other devices.
Q: At the CPU level, is there conversion after assembly?
A: Yes. Machine language is binary. Assembly must be decoded to binary for the hardware.
Q: In the add example, is cache memory utilized?
A: Only the result will go to cache. Cache is for post-processing, not pre-processing. For huge inputs, cache stores changes after processing (e.g., Word document differences until saved).
Q: Are the positions of opcode and registers fixed in the instruction format?
A: In the machine code example shown, the result register comes first after the opcode, then the source registers. The control unit decodes from machine code and rearranges for assembly.
Q: Why have both L1 and L2 caches per core, and then a shared L3?
A: L2 cache receives instructions from the control unit/program counter. It splits instructions (opcode to L1I, data to L1D) for faster core access. L3 is shared storage for swapping/temporary data across all cores, not for incoming instructions.
Q: Are the register names (R1, R2, R3) fixed in number?
A: No. The number of registers used depends on the number of variables in the program. If you have 10 variables, you need 10 registers.
Q: How does a 10GB CSV file get processed if registers have limited capacity?
A: Data is processed row-wise. Each row's validation becomes separate instructions. The OS loads only necessary instructions into memory. Software (e.g., Spark) partitions the data and identifies instructions/data for the RAM and CPU.
Q: Why are CPUs still 32-bit when operating systems are 64-bit?
A: The CPU's primary job is processing, and 32-bit instructions are sufficient for that. The OS handles more complex communication with memory, disk, network, etc., requiring a wider bit width (64-bit).
Q: How do registers and caches (L1, L2, L3) interact? Does data go to the register first?
A: The core gets instructions from the cache. Registers are temporary storage within the core. The flow is from memory to cache, then to the core/registers.
1. Describe the journey of a simple "add R1, R2" instruction from the point it is fetched from memory until the result is written back. Mention all relevant CPU components (PC, IR, control unit, ALU, registers).
2. A student argues that a 64-bit operating system must be running on a 64-bit CPU. Using concepts from the lecture, explain why this is not strictly necessary, but what the limitation would be.
3. Compare the roles of L1, L2, and L3 cache in a multi-core CPU. Explain why having both L1 and L2 per core is beneficial.
4. A program written in Python (interpreted) and the same logic written in C (compiled) both perform an identical calculation. Explain, from the CPU's perspective, why the C program is likely to execute faster.
One line per segment, [hh:mm:ss] timestamp first.
loading…