session: "5102-foundations-of-comp-sys/2026-10-25 0000 FCS 25 Oct"
title: "FCS 25 Oct"
date: "2026-10-25 00:00"
duration: "--"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 4
transcript_chars: 93491
generated: "2026-11-23T01:35:51+05:30"
FCS 25 Oct
Overview
This class focused on the precise boundary between hardware and software in a computer system. It began by defining the Instruction Set Architecture (ISA) as the contract between machine code and the processor, distinct from any specific CPU implementation (microarchitecture). The session then compared major ISA families (x86-64, ARM64, RISC-V) from a whole-system perspective, considering factors like compatibility, performance, and ecosystem. Finally, it explored the mechanisms by which hardware and software interact, covering Input/Output techniques (polling, interrupts, DMA, memory-mapped I/O) and demonstrating how to use Linux commands to inspect system hardware, architecture, and device activity.
Learning outcomes
- Distinguish between the ISA (the software-visible contract) and microarchitecture (a specific CPU implementation).
- Compare the x86-64, ARM64, and RISC-V architectures using criteria like compatibility, performance, cost, and ecosystem.
- Explain the trade-offs between polling, interrupts, and DMA for handling I/O events.
- Use Linux system inspection commands (
uname, lscpu, /proc/interrupts, lspci, lsusb, evtest) to gather evidence about hardware and system activity. - Describe how a user action (e.g., pressing a power button) initiates a hardware signal that is ultimately handled by the operating system.
Core concepts
Instruction Set Architecture (ISA) as Contract
The ISA is the software-visible contract that defines architectural behavior: instructions and their meaning, architectural registers, memory access rules, encodings, specified exceptions, and privileged behavior. It is what machine code can expect from any compliant processor. This is distinct from microarchitecture, which is how a particular CPU implements the ISA (e.g., pipeline width, cache hierarchy). Multiple different microarchitectures can correctly implement the same ISA.
RISC vs. CISC as Design Philosophy
RISC (Reduced Instruction Set Computer) and CISC (Complex Instruction Set Computer) are more useful as sets of design questions than as a simple "simple vs. complex" slogan. Modern processors often incorporate ideas from both philosophies, complicating any simple categorization. The distinction is about design trade-offs, not inherent superiority.
Input/Output Mechanisms
Systems use a combination of mechanisms for device communication:
- Polling: The CPU repeatedly checks a device for work. Trade-off: frequent polling wastes CPU cycles; infrequent polling increases detection latency.
- Interrupts: A device signals the CPU that an event needs attention, causing the CPU to jump to a handler. This does not guarantee immediate application processing due to kernel handling and scheduling.
- DMA (Direct Memory Access): A hardware feature allowing a device to transfer data directly to/from system memory without CPU involvement for each byte. The CPU configures the transfer and is notified upon completion.
- Memory-Mapped I/O: Device registers are mapped into the processor's address space. Accesses to these addresses have device-specific side effects and rules, unlike ordinary RAM accesses.
System Inspection via Linux
The operating system exposes hardware information through files and commands. This provides evidence of system state but not a complete explanation. Key tools include:
uname -m, lscpu, /proc/cpuinfo for CPU architecture and topology./proc/interrupts for interrupt counters per CPU.lspci, lsusb for listing connected devices.evtest for testing input devices like keyboards and buttons.
Formulas and maths
(No formulas were presented in this session.)
Worked examples
RISC-V Register Specification
- Example: The RV64I base ISA defines 32 integer architectural registers, with register
x0 hardwired to the value 0.
Polling Interval Trade-off
- Scenario: Files arrive every 3 seconds.
- If you poll every 1 second, you waste two polls between arrivals.
- If you poll every 4 seconds, a file arriving at second 5, 6, or 7 is not detected until second 8, causing a delay.
Linux Command Output
uname -m output: x86_64lscpu output (on lecturer's VM):- CPU op-mode(s):
x86_64 - CPU family:
6 - Model:
165 - CPU(s):
2 - Thread(s) per core:
1 - Core(s) per socket:
1 - Socket(s):
2 - Stepping:
2 - Performance Observation: A CPU-intensive mining process was slow on a 2-CPU VM. The lecturer stated that with four CPUs, the process would complete much faster ("three seconds, two seconds").
- Monitoring Command:
watch -n 1 cat /proc/interrupts refreshes the interrupt counters every second.
Questions asked in class
- Q: Imagine two processors running the same program, must their internal designs be identical?
- A: No. The internal pipeline (microarchitecture) need not be identical. Binary compatibility depends on the ISA and platform conventions, not the chip's internal design.
- Q: Asked about "optional vector extension."
- A: This refers to an optional standard extension to an ISA (e.g., RISC-V Vector extension). Chip designers choose to include it based on power, area, and workload. Software using it requires both hardware support and software libraries.
- Q: Difference between OpenOnload and DMA?
- A: DMA is a hardware feature for direct device-memory transfers. OpenOnload is a software framework that uses advanced hardware features (like DMA and OS bypass) specifically to accelerate network applications.
- Q: How do real systems choose between interrupts and polling? Do any use both?
- A: It is configurable. Systems can use both for different purposes. Example: a stock exchange might use polling to detect price updates (unknown interval), interrupts for database notifications, and DMA for data movement.
- Q: In an ETL pipeline reading from S3, processing, then writing to a database, where is DMA used?
- A: DMA is typically used between memory and the database (storage), where the device accesses memory directly. Between S3 and memory, processing (formatting) usually involves the CPU, so DMA is not used there.
- Q: When a device DMAs data into memory, how does the CPU avoid reading stale cached copies?
- A: The instruction set architecture and operating system implement mechanisms to ensure cache coherence. The specific mechanism was not covered in this session.
Key takeaways
- The ISA is a contract; microarchitecture is an implementation. Many implementations can satisfy the same ISA contract.
- Internal decomposition of complex instructions into micro-operations is a microarchitectural choice, not an ISA change.
- Choosing an architecture (x86-64, ARM64, RISC-V) involves trade-offs: compatibility, performance, cost, power, ecosystem, and customization.
- Polling is efficient for predictable, high-frequency events but wastes CPU cycles if overused. Interrupts are efficient for unpredictable events but involve handling overhead.
- DMA allows devices to transfer data directly to/from system memory, "bypassing" the CPU for the copy operation, which improves efficiency for large transfers.
- Memory-mapped I/O places device registers in the address space; reading/writing these addresses triggers device actions, not ordinary memory accesses.
- Linux commands like
lscpu and inspecting /proc provide evidence of hardware configuration and activity (e.g., CPU topology, interrupt counts), but not a full explanation of system behavior. - User actions (e.g., power button press) generate hardware signals that are communicated to the OS via mechanisms like interrupts.
- A CPU-intensive process's performance can scale with the number of available CPUs/cores.
- The statement "bypass DMA" is incorrect terminology; DMA is the bypass mechanism.
- Network communication always involves a Network Interface Card (NIC).
- RISC vs. CISC is a design philosophy discussion, not a binary classification of modern CPUs.
Exam-style questions
1. A program compiled for x86-64 runs correctly on both an Intel Core i7 and an AMD Ryzen CPU. Explain how this is possible given that their internal designs differ.
- Outline: Both CPUs implement the same ISA (x86-64). The ISA defines the architectural contract (registers, instruction behavior, memory model) that the machine code expects. While their microarchitectures (pipelines, caches, branch predictors) differ, they both correctly implement this contract, ensuring binary compatibility.
2. Describe a scenario where using polling for I/O would be preferable to using interrupts, and another scenario where the opposite is true. Justify your choices.
- Outline (Polling preferable): High-frequency, predictable events (e.g., checking a sensor reading in a tight control loop every microsecond). Interrupt overhead would dominate. Outline (Interrupts preferable): Low-frequency, unpredictable events (e.g., a keyboard key press). Polling would waste vast amounts of CPU time waiting for an event that rarely occurs.
3. You use lscpu on a system and see: "CPU(s): 4", "Thread(s) per core: 2", "Core(s) per socket: 2", "Socket(s): 1". Explain what this tells you about the system's hardware configuration.
- Outline: The system has 1 physical chip (socket). That chip contains 2 physical cores. Each core supports 2 hardware threads (Hyper-Threading or SMT), resulting in 4 total logical CPUs visible to the operating system.
4. What is the primary purpose of Direct Memory Access (DMA), and how does it change the role of the CPU during a large data transfer from a disk to memory?
- Outline: The primary purpose of DMA is to offload bulk data transfers from the CPU. Without DMA, the CPU must read each byte from the device and write it to memory. With DMA, the CPU only configures the transfer (source, destination, size), and a dedicated DMA controller performs the copy. The CPU is free to do other work and receives an interrupt only upon completion.
Glossary
- Instruction Set Architecture (ISA) - The software-visible contract defining instructions, registers, memory rules, and exceptions.
- Microarchitecture - The specific hardware implementation of an ISA (e.g., pipeline, caches).
- Polling - Actively repeatedly checking a device for status or data.
- Interrupt - A signal from a device requesting immediate attention from the CPU.
- DMA (Direct Memory Access) - Hardware mechanism for direct data transfer between device and memory without CPU per-byte involvement.
- Memory-Mapped I/O - Mapping device control registers into the processor's address space.
- Binary Compatibility - The ability for a compiled program to run on different systems fulfilling the same ISA and platform contract.
- Architectural State - The state (register and memory values) observable by software according to the ISA.
Follow-ups
- TBB (Threading Building Blocks): The lecturer noted, "Totally forgot about that. I will definitely cover it." This will be addressed in a future session.
- CPU Cache Coherence during DMA: The question about stale cached copies was answered at a high level ("instruction set"), but the detailed mechanism is to be covered later.
- Architecture Comparison Table: A table comparing x86-64, ARM64, and RISC-V from a "whole evaluation system" perspective was mentioned as a starting point but not detailed.
- Practical Tools: Tools like
tcpdump and the full functionality of evtest were alluded to but not demonstrated. Their practical use is "not covered in this session."