How Computers Work

Find out what happens inside a computer when it runs a program. Learn the parts of the von Neumann design and how buses and devices connect them, how logic gates and the processor carry out instructions in the fetch-decode-execute cycle, and how programs become machine code. Compare memory and storage, see why caches make computers fast, and discover how the operating system starts the computer, loads programs into memory and keeps everything working together.

BeginnerLesson 3 of 7 in Introduction to Computer Science Course

What you will learn

  1. Identify the main hardware parts of a computer, explain the stored-program idea behind the von Neumann architecture, and describe how buses and input and output devices connect everything.
    • Identify the main parts of a computer and the stored-program idea
      Distinguish hardware from software and describe the von Neumann architecture: a processor, one memory for both instructions and data, input and output, and the connections between them.
    • Explain how buses carry addresses, data and control signals
      Describe the address, data and control parts of the system bus, follow a memory read and write, and calculate how bus width limits addressable memory and transfer speed.
    • Classify input and output devices and explain how they connect to the CPU
      Sort devices by their role, explain conversion between analog signals and digital data, and describe how controllers, drivers, interrupts and direct memory access let slow devices work with a fast processor.
  2. Show how transistors and logic gates compute with bits, name the parts of the CPU, trace the fetch-decode-execute cycle, and explain what makes one processor faster than another.
    • Use logic gates to see how hardware computes with bits
      Read the truth tables of the basic logic gates, work out the output of a small circuit, and explain how gates built from transistors add numbers and store bits.
    • Name the parts of the CPU and what each one does
      Describe the control unit, the arithmetic logic unit, the general-purpose and special registers, the clock and the cores, and the job each one does when a program runs.
    • Trace the fetch-decode-execute cycle
      Follow the steps the CPU repeats for every instruction, track the registers through a short program, and explain how jumps and interrupts change what runs next.
    • Explain what makes a processor faster
      Compare the effects of clock speed, number of cores, cache size and pipelining, and estimate how each one changes the time a task takes.
  3. Describe machine code and instruction sets, read a short assembly program, and explain how compilers, assemblers, linkers and interpreters turn source code into a running program.
    • Read machine code and assembly language
      Explain what a machine instruction contains, why an instruction set ties programs to a processor family, and how assembly language makes machine code readable.
    • Explain how compilers and interpreters turn source code into running programs
      Compare compiling and interpreting, follow the steps from a source file to an executable, and explain bytecode, virtual machines and why the same program can run on different computers.
  4. Compare main memory with the different kinds of secondary storage, explain the memory hierarchy and caching, and choose suitable storage for a task.
    • Describe main memory and how it is addressed
      Explain RAM and ROM, volatility, byte addresses and capacity units, and why a program must be in main memory to run.
    • Compare secondary storage technologies
      Explain how hard disks, solid-state drives, flash media, optical discs, magnetic tape and cloud storage keep data, and choose storage by capacity, speed, cost, durability and portability.
    • Explain the memory hierarchy and caching
      Order the levels from registers to archive storage by speed, size and cost, explain why caches work, and calculate how cache hits and misses affect the average access time.
  5. Describe what an operating system does, how a computer starts, and how the operating system loads programs into memory, runs them on the processor and keeps them apart.
    • Describe the role of the operating system
      Explain how the operating system manages the processor, memory, storage and devices, provides a user interface and file system, and keeps users and programs secure.
    • Follow how a computer starts and runs a program
      Trace the boot sequence, follow how the operating system loads a program into memory and starts it, and explain how virtual memory keeps programs apart and lets them use more memory than is installed.

How Computers Work study guide

5 chapters

1

Computer parts and the paths between them

A computer becomes easier to understand when you separate the jobs its parts perform. Input brings in data, the processor follows stored instructions, memory supplies working contents, and output presents results. The connections matter as much as the components: follow an address, a value and a control signal to see how a processor reaches memory and devices, then see how slower devices request attention.

1.1 The parts that make a computer work

A computer accepts input, follows instructions to process it, stores data, and produces output. These roles apply to a laptop and to a controller hidden inside a washing machine. The difference is the task and the equipment attached to it.

Physical parts and programs

Hardware is the physical equipment. Software consists of programs and the data they work on. The CPU is the processor chip, not the whole computer case. A motherboard connects it to RAM, storage, a GPU, power and device ports. The GPU handles drawing and other work that applies similar operations to many values. A phone combines many of these functions in a system on a chip (SoC).

RAM holds instructions and data being used now. A storage drive keeps programs and saved files without power. In a computer described as having 16 GB of memory and a 512 GB SSD, the first capacity describes RAM and the second describes storage. A larger drive does not provide more working RAM.

A program stored as data

The von Neumann architecture has a CPU, main memory holding both instructions and data, input/output devices, and buses connecting them. John von Neumann described this design in the 1945 "First Draft of a Report on the EDVAC." Its central idea is the stored program: instructions are binary values in memory, ready for the CPU to fetch.

Earlier machines such as ENIAC were set up for tasks with switches and cables. Loading a new program lets a stored-program machine change jobs without rewiring. The Manchester Baby ran a program in rewritable electronic memory on June 21, 1948.

Memory does not attach a meaning to each pattern. The byte 01000001 can represent the number 65, the ASCII letter "A", or part of an instruction. What the CPU or program does with the pattern determines its meaning. During an instruction fetch, the CPU treats the fetched pattern as an instruction.

Why the processor can wait

Instructions and data share the route between the CPU and main memory. Memory also supplies them more slowly than the CPU can use them. This restriction is the von Neumann bottleneck. A fast processor can therefore spend time waiting for the next value. Small, fast caches keep useful copies near the CPU and reduce many of these waits.

DesignInstructions and dataUseful consequence
Von NeumannShare main memory and its pathOne memory holds a changing mixture of code and data.
HarvardHave separate memories and pathsAn instruction and a data value can be fetched together.

Small microcontrollers and signal processors often use a Harvard design. Modern general-purpose CPUs combine the ideas: shared main memory, but separate level 1 instruction and data caches.

Computers inside other devices

An embedded system does a dedicated job inside a larger device. A thermostat reads a temperature sensor, processes the reading, and controls heating. Its stored program usually stays in non-volatile memory. The processor, memory and input/output roles are still present, even without a keyboard, screen or full desktop operating system.

Key Takeaways

  • Hardware is physical equipment; software supplies programs and data.
  • The CPU is one component, distinct from RAM, storage and the computer case.
  • A stored-program computer fetches binary instructions held in memory.
  • A bit pattern gets its meaning from how it is used.
  • Caches reduce waiting caused by the CPU–memory bottleneck.

1.2 How addresses, values and commands travel

A processor needs three things to access memory: a location, the value to transfer, and a command telling memory what to do. Keeping these roles separate makes a bus transaction much easier to follow.

Three roles on a classic system bus

A bus is a shared communication path. In a classic parallel system bus, several wires or circuit-board tracks carry bits at the same time.

Bus partWhat it carriesDirection in a CPU memory access
Address busThe location to useFrom CPU toward memory or a device
Data busAn instruction or data valueToward CPU for a read; away for a write
Control busRead, write, timing and interrupt signalsDepends on the signal

An address names a location; it is not the value stored there. Address 200 can hold 7 today and 9 later without changing its address. A useful comparison is a numbered mailbox: the number identifies the box, while its contents can change.

Follow a read and a write

To read address 200, the CPU puts 200, binary 11001000, on the address bus and sends a read command on the control bus. Memory returns the value at that location, here 7, on the data bus. The CPU copies it into a register.

To write 9 at address 201, the CPU puts 201 on the address bus, 9 on the data bus, and a write command on the control bus. Memory replaces the contents of location 201. Sending 201 on the data bus would send the wrong value; the address and the contents have different jobs.

Address width limits the number of locations

With n address bits there are 2n different addresses. If each address names one byte, that is also the number of addressable bytes.

  • 16 bits give 216=65,536 addresses, or 64 KiB.
  • 32 bits give 232=4,294,967,296 addresses, or 4 GiB.
  • Increasing from 20 to 21 bits doubles capacity from 1 MiB to 2 MiB.

Every extra bit doubles the combinations. Doubling the bit count from 16 to 32 multiplies the location count by 216; it does not merely double it. This calculation gives an addressing limit, not the amount of RAM actually installed.

Data width limits each transfer

A 64-bit data path carries 8 bytes in one transfer. An 8-bit path needs four transfers to carry a 4-byte value. Bandwidth measures how much data can move per second:

bandwidth=bytes per transfer×transfers per second

At 1 billion transfers per second, an 8-byte path carries 8 billion bytes per second, or 8 GB/s. Address width controls how many locations can be named; data width controls how much moves at once.

A CPU's word is its natural working size, commonly 32 or 64 bits. A 64-bit processor does not require every connection to have 64 wires. Its implemented address range can also use fewer than 64 bits.

Modern links keep the same jobs

Memory channels, PCI Express and USB replace one shared bus with several links. PCI Express and USB are serial: bits travel one after another over fast wire pairs. Addresses, values and commands are packed into messages. They still identify a destination, carry contents and coordinate the transfer.

Key Takeaways

  • An address identifies a location; data is the content transferred.
  • Read and write commands travel as control signals.
  • An n-bit address has 2ⁿ possible values; byte addressing makes the capacity 2ⁿ bytes.
  • Each extra address bit doubles the address range.
  • Bandwidth equals bytes per transfer multiplied by transfers per second.
  • Serial links carry addressing, data and control information in messages.

1.3 Getting data into and out of a computer

An input device supplies data; an output device presents a result or acts on it. The classification describes the device's role in the system. It does not describe how complicated the device is inside.

Classify the action

Keyboards, cameras, microphones, barcode readers and sensors supply input. Screens, printers, speakers and actuators supply output. An actuator changes something physical, such as opening a valve or turning a motor.

Some devices do both. A touchscreen senses touches and displays images. A headset combines a microphone with speakers. A network adapter sends and receives data. Storage drives also perform reads and writes through I/O controllers, but their main purpose is keeping data, so they form the separate category secondary storage.

A printer can contain a processor that turns a page into printable dots. It remains an output device because of what it does for the computer. A wireless mouse supplies input just as a wired one does.

Turn continuous signals into numbers

Sound and temperature vary continuously: they are analog signals. An analog-to-digital converter (ADC) measures a signal at regular intervals and encodes the samples as numbers. A digital-to-analog converter (DAC) turns digital values into an analog output, such as the signal driving a speaker.

For one audio channel sampled 44,100 times each second with 16 bits per sample:

44,100×16=705,600 bits per second

This is the raw sample data rate. Each second contains 44,100 measurements, and each measurement needs 16 bits. Sampling and encoding let a computer store and process the recording.

Hardware controller, software driver

Devices connect through ports or wireless links such as USB, HDMI, Bluetooth or Wi-Fi. A device controller is circuitry that handles low-level communication and exposes registers the CPU can read or write. A device driver is software that translates OS requests into commands for the device. The controller is hardware; the driver is software.

Let devices ask for attention

With polling, the processor repeatedly checks a status register. This is simple, but a device that is usually idle can cause many checks with no useful result.

With an interrupt, the controller signals when attention is needed. The CPU completes the current instruction in the simple instruction-cycle model, saves the interrupted state, and runs an interrupt handler. It then restores the saved state and continues. A key press or completed disk read can trigger this sequence.

People and many devices act far more slowly than a CPU. A person types only a few characters per second, while a processor can execute billions of instructions per second. Interrupts let the CPU work between events.

For a large transfer, direct memory access (DMA) lets a device or DMA controller move a block directly to or from RAM. The CPU sets up the operation and works on something else. A completion interrupt tells it when the block is ready. DMA removes the need for the CPU to copy every byte; it still participates in arranging and completing the transfer.

Key Takeaways

  • Classify input and output by the action performed for the computer.
  • An ADC encodes sampled analog input; a DAC produces analog output.
  • A controller is hardware, while a driver is software.
  • Polling checks repeatedly; an interrupt signals that attention is needed.
  • DMA transfers blocks between a device and RAM without CPU copying of every byte.
2

How a processor carries out work

Inside a processor, simple circuits combine into a machine that can follow a program. Start with gates acting on bits, then identify the registers and control signals that move an instruction through the CPU. A short trace makes the changing state visible. Clock speed, cores, caches and pipelines explain why executing the same useful work can take different amounts of time on different systems.

2.1 From switches to calculations

A computer's smallest operations come from circuits that switch between two signal levels. A high voltage represents 1 and a low voltage represents 0. These levels stand for bits; a chip does not recognize the meaning of a photo or a sentence.

Gates turn input bits into an output

A transistor acts as an electronically controlled switch. Small groups form logic gates, each with a fixed input/output rule. A truth table lists every input combination and its output. With two inputs there are four combinations; in general, n inputs need 2n rows.

NOT reverses its single input. The two-input gates behave as follows:

ABANDORXORNANDNOR
0000011
0101110
1001110
1111000

AND needs both inputs to be 1. OR needs at least one, including both. XOR needs different inputs. NAND reverses AND; NOR reverses OR. Reading OR as "one but not both" confuses it with XOR.

To evaluate (A AND B) OR (NOT C) for A = 1, B = 0, C = 0, work from the inputs outward. A AND B gives 0. NOT C gives 1. Finally, 0 OR 1 gives 1. Write down the intermediate outputs so the final gate receives the correct inputs.

Gates add binary digits

A half adder takes two bits. Its sum output is XOR and its carry output is AND. For two input 1s, the sum bit is 0 and the carry bit is 1: the two-bit result is 10, meaning 2.

A full adder also accepts a carry from the preceding column. Chaining these circuits lets an ALU add longer numbers. Follow 0110 plus 0011 from the right:

  1. The rightmost column gives 1, with no carry.
  2. The next column has two 1s: write 0 and carry 1.
  3. The next has 1, 0 and carry 1: write 0 and carry 1.
  4. The leftmost has 0, 0 and carry 1: write 1.

The result is 1001, or 9. A carry belongs to the next column; dropping it changes the value.

Gates can hold a bit

Feedback means feeding a circuit's output back into its input. Cross-coupled NAND or NOR gates form a latch that holds one bit while power remains on. A flip-flop captures a new bit at a clock edge, keeping updates in step with the processor's clock. Registers use clocked storage circuits. SRAM cache cells use latch-style circuits; DRAM stores charge in capacitors.

NAND and NOR are each universal: either gate type alone can build any logic function. Connecting both NAND inputs to A gives A NAND A, which acts as NOT A.

These are layers of abstraction. Transistors build gates; gates build adders, registers and control circuits; these build a processor that executes instructions. A programmer can use the instruction layer without designing the switches underneath it.

Key Takeaways

  • Truth tables enumerate every input combination.
  • OR includes the case where both inputs are 1; XOR excludes it.
  • Evaluate a circuit through its intermediate gate outputs.
  • A half adder produces an XOR sum and an AND carry.
  • Feedback stores bits; clock edges control flip-flop updates.
  • NAND and NOR are each sufficient to build any logic function.

2.2 The processor’s working parts

The CPU, or processor, executes a program's instructions. Its control unit directs work, its arithmetic logic unit performs operations, and its registers hold the values needed immediately. A clock coordinates changes in these circuits.

Direct the work and perform it

The control unit fetches an instruction, decodes it and issues control signals. It might tell memory to return a value, select two inputs for the ALU and enable a register to store the result. It coordinates the operation; the ALU does the arithmetic or logic.

ALU operations include addition, subtraction, comparisons, bit shifts and gates such as AND and XOR. Results also update status flags. A zero flag indicates a zero result; a negative flag records a negative result. A branch can test a flag to choose the next instruction.

Registers hold the immediate working state

Registers are very small, fast storage locations inside the processor. A general-purpose register usually holds one word. For example, x86-64 provides 16 general-purpose integer registers, and 64-bit ARM provides 31. Programs use them to keep values close to the ALU.

The textbook processor makes the following roles visible:

RegisterRole
Program counter, PCAddress of the next instruction to fetch
Memory address register, MARAddress for the next memory read or write
Memory data register, MDRValue just read or about to be written
Current instruction register, CIRInstruction being decoded and executed
Accumulator, ACCWorking value and ALU result in the teaching machine

MDR is also called the memory buffer register (MBR). CIR is also called the instruction register (IR). Actual chips organize these jobs in more complex ways, but the model lets you follow the movement of an instruction and its data.

The PC holds an address, not a total of instructions completed. A jump can send it backward to repeat a loop. MAR and MDR also differ: an address such as 10 goes into MAR; the value stored at address 10 goes into MDR.

A clock cycle is one timing step

Clock speed counts pulses per second, measured in hertz (Hz). A 3 GHz clock produces 3 billion cycles each second. The duration of one cycle is:

13,000,000,000 s≈0.33 ns

A pulse lets parts of a circuit advance. Some instructions need several timing steps, and modern processors overlap work on several instructions.

More than one processing core

A core has the control, arithmetic, register and cache resources needed to run an instruction stream. Four cores can carry out four streams at once. A program benefits when its work can be divided among them; merely owning four cores does not split every task.

A GPU has many smaller processing units suited to performing similar operations on many data items. Drawing pixels, processing video and some machine-learning calculations have this form. A CPU suits a wider mix of instructions and decisions.

Think of a kitchen: the control unit assigns actions, the ALU performs them, registers hold ingredients at hand, and memory supplies more. The CPU follows bit patterns mechanically; the useful meaning comes from the program.

Key Takeaways

  • The control unit coordinates operations; the ALU performs arithmetic and logic.
  • Flags record conditions such as a zero result for later branches.
  • PC, MAR, MDR, CIR and ACC hold different parts of the current working state.
  • A clock cycle is a timing step, not necessarily a completed instruction.
  • Multiple cores help work that can run in parallel.

2.3 Follow an instruction through the CPU

The fetch-decode-execute cycle connects the processor's parts into a running program. Each cycle brings in an instruction, determines its operation and carries it out. A trace records the changing registers and memory so each result has a visible cause.

Fetch the instruction

In the simple processor, fetch follows this sequence:

  1. Copy the PC into the MAR.
  2. Put the address on the address bus and send a memory-read signal.
  3. Receive the instruction over the data bus into the MDR.
  4. Copy it into the CIR.
  5. Advance the PC to the next instruction.

In the teaching machine each instruction occupies one location, so the PC increases by 1. A byte-addressed processor advances by the instruction's byte length. During execution the PC already points beyond the fetched instruction.

Decode, then execute

The control unit separates the opcode, which specifies the operation, from the operand, which supplies a value, register or address. It then sends the signals needed to execute the instruction. A load reads data, an add uses the ALU, a store writes data, and a jump changes the PC. Some descriptions call writing the result a separate write-back stage.

Trace a complete program

The teaching machine has one accumulator. Here LOAD, ADD and STORE use memory addresses as operands.

Address  Instruction      Data address  Value
0        LOAD 10          10            7
1        ADD 11           11            5
2        STORE 12         12            0
3        HALT

Start with PC 0. Fetching LOAD 10 moves the PC to 1. Execution puts address 10 in MAR, reads 7 through MDR, and sets ACC to 7. The operand 10 names a location; it is not the value loaded.

Next, ADD 11 is fetched and PC becomes 2. Memory location 11 supplies 5. The ALU adds 7 and 5, leaving ACC 12. Fetching STORE 12 advances PC to 3. Execution places address 12 in MAR and value 12 in MDR, then writes 12 to that location. ACC remains 12. Finally, fetching HALT advances PC to 4 and execution stops the teaching machine. Four instructions have run.

Branches replace the next address

JUMP 0 puts 0 into PC during execution, regardless of its previous value. JUMPZ 6 jumps only when ACC is zero. If that instruction was fetched from address 4, fetch first makes PC 5. Execution then sets PC to 6 when ACC is zero; otherwise PC stays 5. This is how a sequence can choose a route or repeat a loop.

Interruptions and real processors

At an instruction boundary in this model, the CPU checks for interrupts. To handle one, it saves the PC and other working registers, runs the handler, then restores the saved state. The interrupted program resumes with its own values and next address.

A CPU does not fetch a whole source program at once. It executes machine instructions, often several for one source statement. Modern CPUs overlap and reorder internal work while preserving the program's required results.

Key Takeaways

  • Fetch reads the instruction through MAR and MDR into CIR.
  • PC advances during fetch; execution of a jump can replace that address.
  • An address operand must be used to read the value stored there.
  • STORE writes ACC to memory without changing ACC in this teaching machine.
  • Interrupt handling saves and restores the interrupted working state.
  • Real processors overlap work while preserving the required program results.

2.4 Why a program finishes sooner

Processor performance depends on the work a program needs and how quickly the computer completes that work. Clock speed, useful work per cycle, waiting time and opportunities for parallel work all matter.

Clock speed and a fixed cycle count

For a task requiring a known number of clock cycles:

time=cycles requiredcycles per second

A task needing 6 billion cycles takes 2 seconds at 3 GHz and 1.5 seconds at 4 GHz. The comparison holds the cycle count fixed. Across different processor designs, a program may need different numbers of cycles. A 3.5 GHz chip can therefore outperform a 4 GHz chip by finishing more useful instructions per cycle.

Higher clock rates also use more power and produce heat. Thermal throttling reduces the clock when a processor gets too hot. This helps explain why performance gains have come from more than raising gigahertz.

Cores divide only the parallel part

Suppose a task takes 10 seconds on one core. Two seconds must happen in sequence; eight seconds can be divided evenly among four cores. Ignoring coordination overhead:

2+84=4 seconds

Dividing the whole 10 seconds by four gives 2.5 seconds, but incorrectly divides the sequential work. Even unlimited cores cannot remove those two seconds. Multiple cores also help separate programs run at the same time, even when each program uses only one core.

A pipeline overlaps stages

In a three-stage pipeline, one instruction executes while the next decodes and another fetches. Each instruction still passes through all three stages. The gain is more instructions completed over a period of time.

If each stage takes one cycle, ten independent instructions take 30 cycles without overlap. An ideal pipeline needs three cycles to finish the first instruction and one more for each remaining instruction:

3+(10−1)=12 cycles

A branch can make instructions already fetched useless. Discarding that work costs cycles, so processors predict branches. Real dependencies and memory waits also keep a pipeline from always reaching its ideal rate.

Keep the processor supplied

A cache holds nearby copies of instructions and data. More useful cache capacity can reduce trips to RAM, especially when a program repeatedly uses a working set that did not fit before. If that working set already fits, extra capacity may help little.

Memory bandwidth limits how fast many values can arrive. Storage speed matters when opening files or starting applications: moving from a hard disk to an SSD can reduce the delay even though the CPU is unchanged. Word size and the instructions a processor supports also affect suitable workloads.

More transistors, different uses

Moore's law describes Gordon Moore's observation, first made in 1965 and revised in 1975, that transistor counts doubled about every two years. This historical trend is not a rule that programs become twice as fast on a fixed schedule. As scaling has slowed, chip designers have used additional transistors for cores, caches, GPUs and specialized accelerators. A useful comparison asks how long the same task takes under the same conditions.

Key Takeaways

  • Compare execution time for the actual task, not clock speed alone.
  • More cores reduce only work that can be divided among them.
  • Pipelining raises throughput by overlapping instruction stages.
  • Cache, memory bandwidth, storage and heat can limit useful CPU work.
3

How written programs become machine instructions

A readable program and the instructions a CPU executes are different forms of the same intended work. Assembly exposes individual operations and branches; compilers and interpreters connect high-level code to those operations. Following a build shows why a source file differs from an executable, why libraries matter, and why moving software to another platform may require a new build or a suitable runtime.

3.1 Reading the instructions a processor runs

Machine code is binary instructions for a particular kind of processor. Assembly language writes those instructions with readable names. Both describe operations much closer to the hardware than a high-level language such as Python or C.

Operations and operands

An instruction contains an opcode specifying what to do and usually one or more operands specifying what to use. An operand can name a register or memory address, or supply a value directly. Its meaning comes from the instruction's defined format.

Consider an 8-bit teaching encoding. The first four bits hold an opcode; the last four hold an address. If LOAD is 0001, then LOAD 10 becomes 0001 1010, because decimal 10 is binary 1010. Four opcode bits allow 24=16 operation codes. Four address bits name locations 0 through 15. This encoding illustrates a limited format; the other teaching-machine traces use written instructions with larger addresses.

An instruction set architecture (ISA) defines the instructions, encodings and registers a processor offers. x86-64, ARM and RISC-V are examples. ARM's A64 instructions are 32 bits long; x86-64 instructions range from 1 to 15 bytes. A 64-bit processor's word size does not determine every instruction's length.

A readable loop

An assembler turns assembly mnemonics and labels into machine code for an ISA. Useful instruction groups include data transfer, arithmetic and logic, control flow, and system or I/O operations.

This accumulator program counts down from 3. SUB 21 subtracts the contents of address 21. JUMPZ branches if ACC is zero.

0  LOAD 20
1  SUB 21
2  STORE 20
3  JUMPZ 5
4  JUMP 0
5  HALT

20 holds 3; 21 holds 1.

On the first pass, LOAD reads 3, SUB leaves 2, and STORE saves 2. The zero test fails, so JUMP 0 starts another pass. The second pass saves 1 and jumps back. The third saves 0, so JUMPZ 5 goes to HALT.

The first two passes use five instructions each. The last uses four before HALT, which also counts as an instruction: 5+5+4+1=15. Counting only the six written lines misses repeated executions.

One source statement, several instructions

A high-level statement such as total = price + tax can become operations to load a value, add another and store the result. High-level languages express variables, choices, loops and functions without naming every register. Assembly usually maps each written instruction to one machine instruction and depends closely on its ISA.

Machine code for x86-64 cannot execute natively as ARM code. The source can be recompiled for ARM, or a translation or emulation layer can handle the mismatch.

RISC and CISC

RISC designs such as ARM and RISC-V favor simple, regular instructions. Many use fixed-length instructions, but RISC-V can mix 16-bit compressed forms with standard 32-bit instructions. CISC designs such as x86 offer more complex, variable-length instructions. Modern x86 processors break instructions into simpler internal operations. These labels describe design approaches, not a guarantee that one machine is faster.

Key Takeaways

  • An opcode selects an operation; operands specify its inputs or destinations.
  • An ISA defines the machine-code contract a processor implements.
  • An assembler translates readable mnemonics into machine code.
  • Loops execute some instructions repeatedly, so execution counts differ from line counts.
  • High-level programs need translation or an interpreter implemented in machine code.
  • RISC and CISC describe instruction-set styles, with exceptions to simple length rules.

3.2 From source code to a running program

Source code is readable program text. A processor executes machine instructions, so a tool must bridge the gap. Compilation and interpretation describe ways to do that; many real implementations combine them.

The translation tools
ToolIts work
AssemblerTranslates assembly into machine code
CompilerTranslates code into another form, often machine code or bytecode
InterpreterCarries out a program's operations while it runs

Most compilers work before a program starts. A just-in-time (JIT) compiler works during execution. An interpreter is itself a machine-code program: the CPU executes the interpreter, which performs the source program's operations.

Follow a C build

The command clang hello.c -o hello builds an executable named hello from hello.c. A build tool such as make can arrange compiler commands for the programmer. The main stages are:

  1. Preprocessing: handle directives such as #include <stdio.h>, bringing header declarations into the source.
  2. Compiling: translate the C code into assembly-level operations.
  3. Assembling: encode those operations as machine code in object files.
  4. Linking: connect object code and library references to produce an executable.

Headers describe library interfaces; including a header does not by itself copy the compiled library implementation into the program. Linking supplies the connection to that code. Static linking copies required library code into the executable. Dynamic linking records shared-library dependencies that are loaded and connected when needed.

The executable targets an ISA and an operating-system format. Building for an ARM Mac and an x86-64 Windows computer therefore requires separate native builds. Editing the source also requires rebuilding a compiled executable before the change takes effect.

Errors happen at different stages

A compiler can report syntax errors, such as a missing semicolon in C, and type errors where the language checks types. Successful compilation does not establish that the program solves the right problem. A logic error produces a wrong result. A run-time error occurs while the program executes, such as division by an input value that turns out to be zero.

A simple interpreter may reach an error only after earlier statements have run. Python checks an entire file's syntax first, but an undefined name can still fail only when execution reaches it. The translation method alone does not tell you when every kind of error is found.

Bytecode and virtual machines

Java compiles source into bytecode, instructions for the Java Virtual Machine (JVM). Each supported platform supplies its own JVM. It can interpret bytecode and JIT-compile frequently used sections into the local CPU's machine code. The bytecode stays portable because the platform-specific JVM handles the hardware differences.

CPython also compiles Python into bytecode and executes it with a virtual machine. PyPy uses a JIT compiler, and browser JavaScript engines use JIT compilation too. "Compiled" and "interpreted" describe implementations, not permanent properties of a language.

Ahead-of-time native code usually avoids repeated interpretation work. Interpretation makes an edit-and-run cycle convenient, while bytecode and JIT combine portability with runtime optimization. In every route, the CPU ultimately follows machine instructions, and the OS loads the required executable code into memory.

Key Takeaways

  • Compilers translate code; interpreters carry out operations during execution.
  • A C build involves preprocessing, compilation, assembly and linking.
  • Static linking includes library code; dynamic linking records shared-library dependencies.
  • Compilation can catch syntax errors while leaving logic and run-time errors.
  • Bytecode runs through a platform-specific virtual machine.
  • JIT compilation translates during execution; languages can have different implementations.
  • Native executables depend on both an ISA and an operating-system format.
4

Memory, storage and fast copies

The place where a computer keeps data affects both whether it survives power loss and how quickly it can be used. Compare working RAM with persistent drives, then follow the hierarchy from registers to archives. Storage choices depend on access patterns as well as capacity. Caching explains how a small, fast store can save many slow trips, and a weighted average shows how strongly misses affect the result.

4.1 Working memory and its addresses

Main memory holds the instructions and data currently available to the CPU. For an ordinary application stored on an SSD, the OS first brings the needed code and data into RAM. The CPU then fetches instructions through its memory and cache system.

RAM, DRAM and SRAM

RAM means random-access memory: a location can be reached without going through all earlier locations. Normal working RAM is volatile, so its contents are lost without power. Saving a document copies its data to non-volatile storage.

Main memory uses DRAM, which stores bits as charge in small capacitors. The charge leaks, so the cells need refresh, commonly over a 64 ms refresh interval. SRAM uses latch-style transistor circuits that retain their state while powered. It needs no refresh, but uses more space and costs more per bit. Its speed suits processor caches.

KindHolds a bit usingTypical roleKeeps contents without power?
DRAMCharge in a capacitorMain working memoryNo
SRAMA latch-style circuitCPU cacheNo
Firmware flashTrapped chargeStartup instructionsYes

ROM, or read-only memory, is non-volatile memory associated with fixed instructions such as firmware. Modern UEFI or BIOS firmware normally lives in updateable flash. A phone's advertised file capacity is flash storage, even when a description informally calls it "ROM"; the phone routinely writes files there.

A byte has an address

In byte-addressable memory, each address names one byte. A 4-byte integer starting at decimal address 1000 occupies locations 1000, 1001, 1002 and 1003. The next unused location is 1004. Addresses are often written in hexadecimal, such as 0x7FFE0010, because hex compactly represents bit patterns.

The address identifies where bytes are found. Reading the number written as an address is different from reading the value stored at that address.

Capacity units use two systems

A byte contains 8 bits. Lowercase b means bits; uppercase B means bytes.

Decimal unitBytesBinary unitBytes
kB1,000KiB1,024
MB1,000,000MiB1,048,576
GB1,000,000,000GiB1,073,741,824
TB1,000,000,000,000——

A drive sold as 1 TB contains 1012 bytes. In GiB the count is:

1012230≈931 GiB

Some operating-system displays label this binary count "GB." The different number follows from the unit size; it is not evidence of missing space.

Capacity is different from processor speed

More RAM lets more running programs and data stay ready at once. When working data exceeds RAM, the OS may move pages to storage, making access slower. Extra RAM helps that shortage but does not raise the CPU's clock speed. Deleting saved files frees storage. Closing unneeded programs or tabs can release working RAM.

Key Takeaways

  • Working RAM is volatile; saving transfers data to non-volatile storage.
  • DRAM requires refresh; SRAM uses latch circuits and suits fast caches.
  • Firmware persists without power and can live in updateable flash.
  • Each address in byte-addressable memory names one byte.
  • Decimal GB and binary GiB use different numbers of bytes.

4.2 Choosing storage for the job

Secondary storage keeps programs and files without power. Compared with RAM it offers more capacity at a lower cost per byte, with slower access. Different storage technologies trade speed, cost, portability and durability.

Magnetic disks and solid-state drives

A hard disk drive (HDD) stores magnetic patterns on spinning platters. A moving head seeks the right track, then waits for the desired part of the platter to rotate beneath it. Both movements add access delay.

At 7,200 revolutions per minute, one turn takes:

607,200 s≈8.3 ms

The average rotational wait is half a turn, about 4.2 ms. This is only the rotational part, not the full read time; seeking and transferring also take time. Moving parts also make a working HDD vulnerable to shocks.

An SSD stores charge in flash cells and has no moving parts. Small random reads take tens of microseconds instead of the milliseconds typical of HDD access. SSDs are quiet, resist shocks and suit portable computers. HDDs generally offer a lower cost per terabyte for large collections.

Flash cells tolerate a limited number of erase/write cycles. The controller uses wear leveling to spread writes across cells. USB flash drives, memory cards and phone storage also use flash, though the controller and interface affect their performance.

Optical discs and tape
MediumHow it stores or reads dataUseful setting
CD, DVD, Blu-rayA laser reads marks on a reflective layerDistributing media or storing a disc archive
Magnetic tapeData follows a sequence along a long tapeLarge backups and archives

Typical capacities are about 700 MB for a CD, 4.7 GB for a single-layer DVD and 25 GB for a single-layer Blu-ray disc. Optical media are portable but slow compared with modern drives.

Tape offers low cost for large archives. Its sequential access means the drive must wind to reach a distant file. Disks and SSDs provide direct access, reaching a selected location without traversing all earlier data. Tape therefore suits scheduled bulk backups better than an application that repeatedly opens scattered small files.

Cloud storage is a service

Cloud storage keeps files on equipment in a provider's data centers. The underlying media are still SSDs, HDDs or tape. A network connection adds access and transfer delays. The service offers sharing, remote access and off-site copies, with ongoing fees and dependence on the provider's access controls and reliability.

Match the limiting factor

Access time is the delay before data starts arriving. Transfer rate measures how quickly it flows afterward. Many small file reads repeatedly pay access delay; one large continuous file puts more emphasis on transfer rate.

An SSD suits a laptop's active programs. HDDs suit a server storing 20 TB of video economically. Tape or a cloud archive suits a company's long-term records, while a USB drive is convenient for carrying files. Choose using capacity, access time, transfer rate, cost per byte, power use, reliability and portability. Being made from chips does not make an SSD into working RAM: it remains non-volatile storage behind a storage controller.

Key Takeaways

  • HDD access includes seek and rotational delay; SSDs have no moving parts.
  • Wear leveling spreads flash writes across cells.
  • Tape provides sequential access and suits large archives.
  • Cloud storage uses physical storage reached over a network.
  • Access time and transfer rate measure different parts of a read.
  • Choose storage by the task’s access pattern and practical needs.

4.3 Keeping useful data close to the CPU

A computer combines several kinds of storage because fast access, large capacity and low cost do not come together in one technology. The memory hierarchy puts a small amount of very fast storage near the CPU and larger, slower stores farther away.

The levels of the hierarchy

From fastest and smallest toward slower and larger, the main levels are registers, L1/L2/L3 cache, RAM, SSD, HDD, and archive storage. Cost per byte generally falls as capacity grows.

LevelIllustrative access timeTypical scale
RegistersFraction of a nanosecondA few kilobytes or less
L1 cacheAbout 1 nsTens to hundreds of kilobytes per core
L2 cacheA few nsUp to a few megabytes
L3 cacheAbout 10–20 nsSeveral to tens of megabytes
RAMAbout 50–100 nsSeveral to tens of gigabytes
SSDAbout 20–100 µsHundreds of gigabytes to terabytes
HDDAbout 5–10 msSeveral terabytes

These times show scale, not one fixed specification for every device. Using 1 ns for L1, 100 ns for RAM and 10 ms for a disk, RAM takes about 100 times as long as L1 and the disk about 100,000 times as long as RAM.

Hits, misses and useful copies

A CPU cache uses SRAM to hold blocks copied from main memory. Hardware looks through the cache levels before fetching from RAM. A hit finds the requested contents in the cache. A miss requires a slower-level fetch and can bring a copy into the cache.

The hit rate is hits divided by all accesses. For 950 hits in 1,000 accesses, it is 95%. A miss is not missing or damaged data; it means the fast copy was not available.

Why past access predicts future access

Temporal locality means recently used contents are likely to be used again soon. A loop repeatedly reads a counter and its own instructions. Spatial locality means nearby addresses are likely to be used soon. Reading consecutive list elements has this pattern.

A cache brings in a whole cache line, commonly 64 neighboring bytes, taking advantage of spatial locality. Several levels balance capacity with lookup time: one enormous cache would take longer to search.

Compute the average delay

Suppose a cache check takes 1 ns and a RAM access takes 100 ns. A miss costs both, so it takes 101 ns. At a 95% hit rate:

0.95×1+0.05×101=6 ns

At an 80% hit rate:

0.80×1+0.20×101=21 ns

The second average is 21÷6=3.5 times as large. Weight the full hit cost and full miss cost by how often each occurs. Forgetting the cache check on a miss would change this model's answer.

Caching beyond the processor

The OS caches file contents in RAM. A browser caches downloaded web files on storage, and content delivery networks keep copies near users. They all reuse nearby copies to avoid repeated slow retrieval. Clearing a browser cache removes browser files; it does not clear CPU cache circuits. CPU caches hold small memory blocks, not an organized library of whole documents.

Key Takeaways

  • The hierarchy trades speed and cost per byte against capacity.
  • A cache hit finds a fast copy; a miss fetches from a slower level.
  • Temporal locality reuses contents; spatial locality uses nearby addresses.
  • Average access time weights the complete cost of hits and misses.
  • Browser, file and CPU caches use the same broad idea at different layers.
5

How the operating system puts the parts to work

Opening an application depends on more than a processor and a program file. The operating system assigns memory, shares processor time, checks permissions and offers file and device services. Follow startup from firmware to kernel, then follow a running editor through its memory regions, input events and a save request. Virtual memory connects each process’s view of addresses to the physical RAM it is allowed to use.

5.1 The operating system’s everyday jobs

An operating system (OS) manages hardware and supplies services to applications. Windows, macOS and Linux serve personal computers and servers; Android and iOS serve mobile devices. The visible desktop is only one part of this work.

Manage resources and hide hardware details

As a resource manager, the OS assigns processor time, working memory, files and devices to programs and users. As an abstraction, it provides simpler operations that hide hardware details. A text editor can request "open the file report.txt" without choosing disk tracks or device commands.

FunctionWhat the OS does
Process managementStarts, schedules and ends running programs
Memory managementAssigns memory and enforces separation
File managementOrganizes files, folders and stored data
Device managementCommunicates with devices through drivers
SecurityEnforces accounts and permissions
NetworkingSupplies services for exchanging data

The user interface lets people request this work. A graphical user interface (GUI) uses windows, icons, menus and touch or a pointer. A command-line interface (CLI) accepts typed commands. Commands such as ls on Linux and macOS or dir on Windows list files; scripts can combine commands for repeated tasks.

The kernel controls privileged operations

The kernel is the OS core responsible for hardware control and protected resources. Applications run in user mode with restricted privileges. Kernel code runs in kernel mode with greater privileges. An application requests a protected service through a system call, such as asking the OS to read a file.

The kernel checks permissions and carries out the permitted action. A faulty application cannot simply use a normal user-mode instruction to take control of every device or read another process's protected memory.

Share processor time

The scheduler decides which ready program gets processor time. Short turns on a single processing stream make music playback and document editing appear simultaneous. Multiple cores also allow work to run at the same moment. Some CPUs support hardware multithreading within a core, but time sharing remains necessary when more work is ready than the hardware can execute together.

Give files names and devices drivers

A file system tracks file contents and metadata such as size, dates and permissions. Folders form a hierarchy; a path identifies a file, for example /home/sam/notes.txt on Linux. NTFS, APFS and ext4 are file-system examples.

Deleting a file commonly removes its directory entry and releases its space for reuse. That differs from deliberately overwriting every byte. Old data can sometimes remain recoverable, especially on HDDs; a normal delete is not a secure-erasure guarantee.

A driver translates general device requests into commands a controller understands. Standard drivers handle many keyboards and USB drives, while some devices require a specific driver.

Match software to its role

The OS, drivers and utilities such as backup tools are system software. Browsers, editors, games and spreadsheets are application software. Mobile systems emphasize battery life, touch and app separation; servers support network services. A real-time OS meets specified response deadlines for control tasks. Very simple embedded devices can run one program without a full OS.

Key Takeaways

  • The OS manages shared resources and hides hardware details behind services.
  • System calls request kernel services from restricted user-mode applications.
  • The scheduler shares processor time among ready work.
  • File systems track file contents, names, paths and permissions.
  • Drivers connect general OS requests to device-specific commands.
  • System software runs and maintains the computer; applications perform user tasks.

5.2 From power-on to a saved document

Starting a computer and starting an application involve different stages. Startup brings the operating system into control. Application loading then creates a running process that uses the processor, memory and OS services.

Start with persistent instructions

At power-on, working RAM has no usable running program. The CPU begins with firmware stored in non-volatile memory. On a modern PC, UEFI firmware prepares hardware and performs startup checks, often called the power-on self-test (POST). It selects a boot device and starts a bootloader. The bootloader loads the OS kernel into RAM and transfers control to it. The kernel prepares memory management, drivers and services before the login or home screen appears.

Turn a program file into a process

A program is stored instructions. A process is a running instance, with memory, register state and resources. Separate instances of one editor can keep separate documents even though they started from the same program file.

To launch an application, the OS checks the executable and permission to run it, creates an address space, loads the initially needed code and data, sets up a stack and arranges its starting instruction address. More pages can be loaded when used. The scheduler gives the process time on the CPU, which executes its machine instructions.

Different regions hold different contents
RegionContents
CodeMachine instructions
DataGlobal variables
HeapMemory requested while the program runs
StackActive function calls, local values and return addresses

Calling a function adds stack information; returning releases that call's part. Repeated calls with no stopping point can exhaust the stack, causing a stack overflow. A memory leak happens when a program keeps memory it no longer needs, causing its retained allocation to grow. Simply using a large amount of memory is not enough to diagnose a leak.

Separate addresses from physical locations

Virtual memory gives each process its own address space. The OS and the CPU's memory management unit (MMU) map virtual addresses to physical RAM in pages, often 4 KiB. Two processes can use 0x1000 for different physical locations. Access permissions stop unauthorized reads or writes; the OS can also explicitly allow shared pages.

A prohibited access causes a fault, which can end the process. On Linux or macOS, a C program may report a "segmentation fault." A virtual address names a location in that process's map, not necessarily an identical numbered byte of RAM.

When memory demand is high, the OS can move inactive pages to a swap or page file on storage. Retrieving an illustrative page in 100 µs takes about 1,000 times a 100 ns RAM access. Repeated page movement, called thrashing, can dominate execution time. Reducing active memory demand or adding RAM can help.

Follow a key press through the layers

A keyboard controller signals an interrupt. The OS handler and driver obtain the event and deliver it to the editor process. The editor updates the document in its memory and asks OS graphics services to update the display. Saving asks the file system to write the document to storage. When the process ends, the OS reclaims its memory and resources. Saved data remains; changes kept only in process memory disappear.

Key Takeaways

  • Firmware starts before the bootloader loads the kernel.
  • A process is a running program instance with its own state.
  • Code, data, heap and stack hold different parts of a process.
  • Virtual memory maps process addresses to RAM and enforces access permissions.
  • Swapping uses storage for pages; frequent transfers can cause thrashing.
  • Editing changes working memory; saving writes the document to storage.
  • The OS reclaims process resources when the process ends.

How Computers Work examples

5 Walkthroughs

1

Trace the paths inside a computer

13 steps
Connect the stored-program design to memory transfers and device events.
  1. 1
    IntroductionFollow a simple action

    Opening a photo involves several parts: input requests the action, storage keeps the file, RAM holds working contents, and the processor follows instructions to display it. Instructions share memory with data, the von Neumann design, so one machine can do many jobs.

    We will separate those jobs, trace one memory transfer, and see how devices get attention (an interrupt) without keeping the CPU waiting. These roles also describe a phone or a controller inside a larger device.

  2. 2
    ExplanationLocate the working parts

    The CPU executes instructions. RAM holds the current instructions and data; an SSD or HDD holds persistent files. Input devices supply data, and output devices present results or act on them.

    The motherboard connects these parts. A phone combines many functions in a system on a chip. The complete computer case is not the CPU: the processor is one component inside the system.

  3. 3
    Key InsightPrograms are memory contents

    In the von Neumann design, one main memory holds instructions and data. The CPU fetches binary instructions from it, allowing a new loaded program to give the same hardware a different task.

    A bit pattern has no built-in meaning to memory. The byte 01000001 could represent 65, the ASCII letter "A", or part of an instruction. Its use supplies the interpretation.

  4. 4
    ChallengeChange the job

    A temperature controller and a laptop both contain processors, memory and input/output. Why is the controller an embedded system, and what lets the laptop change from editing text to playing audio?

    ---reveal---

    The controller performs a dedicated job inside another device. The laptop changes tasks by running different stored instructions. The hardware roles stay the same while the program changes the work they perform.

  5. 5
    AnalogyChoose a mailbox, then its contents

    Think of memory locations as numbered mailboxes. The address selects a mailbox; the data is what it contains. A read requests its contents, and a write replaces them.

    In the classic system bus, the address bus selects the location, the data bus carries contents, and the control bus carries the read or write command. Changing contents never renumbers the location.

  6. 6
    ExampleRead address 200

    The CPU wants the contents of memory address 200. It sends 200 on the address bus and asserts a read command on the control bus.

    Memory finds that location and places its contents, here 7, on the data bus. The CPU receives 7 into a register. The address made the selection; the returned data supplies the value. No write occurs, so the contents of location 200 remain 7.

  7. 7
    ExplanationCount locations and transfers

    With 16 address bits, byte-addressable memory has 65,536 locations, or 64 KiB. Adding one address bit doubles that range.

    Data width answers a different question. A 64-bit path moves 8 bytes per transfer. At a billion transfers per second its bandwidth is 8 GB/s. More address bits let you name more locations; more data bits let you move more contents in a transfer.

  8. 8
    ChallengeSeparate the two widths

    A byte-addressable teaching system has 11 address bits and a 16-bit data path. How much memory can it address, and how many bytes move in a transfer?

    ---reveal---

    It can address 211=2,048 bytes, or 2 KiB. The data path carries 2 bytes per transfer because each byte has 8 bits. Multiplying the address count by two would wrongly assume each address names two bytes.

  9. 9
    ExplanationTranslate between signals and values

    A microphone supplies input, and a speaker provides output. Sound varies continuously, while a computer keeps digital values. An ADC samples input and encodes measurements as numbers; a DAC converts digital output values into an analog signal.

    A touchscreen performs two roles: sensing touches supplies input and displaying an image supplies output. A device can contain processing circuitry and still be classified by that role.

  10. 10
    ConnectionController and driver work together

    A controller is hardware that communicates with a device. A driver is software that turns OS requests into commands for that controller.

    Polling repeatedly asks whether the device is ready. With an interrupt, the controller signals when attention is needed. For a large block, DMA can move contents between the device and RAM while the CPU works elsewhere, then signal completion.

  11. 11
    ChallengeAvoid empty checks

    A scanner sends a large image to RAM. The CPU sets up the transfer, continues another task and receives a completion signal. What do DMA and the interrupt each contribute?

    ---reveal---

    DMA moves the image block without CPU copying of each byte. The interrupt announces that the transfer is complete so the OS can handle it. The CPU still arranges the transfer; it simply avoids doing all the byte-moving work itself.

  12. 12
    ChallengeConnect a reading to a result

    A greenhouse controller reads a digital temperature value into RAM, computes a decision and opens a valve. Which are its input and output, and what must pass between memory and the CPU?

    ---reveal---

    The temperature reading is input, and valve actuation is output. The CPU needs both the stored control instructions and the reading from memory. Addressing selects those locations, data transfer carries their contents, and control signals coordinate access.

  13. 13
    RecapRead the whole path

    Identify the role first: input, processing, working memory, persistent storage or output. Then distinguish the location being selected from the contents being moved.

    Stored instructions tell the CPU what to do; buses or modern links carry addressing, values and commands. Controllers and drivers connect devices, while interrupts and DMA let slow or bulky device work share a fast computer efficiently.

2

Build and trace a processor operation

19 steps
Work from gate outputs to registers, a short program and performance estimates.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionMake execution visible
  2. 2
    ExplanationRead a gate rule
  3. 3
    ExampleBuild a carry
  4. 4
    ChallengeEvaluate the intermediate outputs
  5. 5
    ConnectionKeep a result between steps
  6. 6
    ExplanationAssign the processor jobs
  7. 7
    ChallengeKeep address and contents apart
  8. 8
    ExplanationFetch before using the instruction
  9. 9
    ExampleFirst instruction: load
  10. 10
    ExampleSecond instruction: add
  11. 11
    ExampleThird and fourth: store and halt
  12. 12
    ChallengeTake or skip a branch
  13. 13
    Key InsightResume after an interrupt
  14. 14
    ExampleCompare a fixed cycle count
  15. 15
    ExampleDivide only the parallel work
  16. 16
    ExplanationOverlap stages, not meanings
  17. 17
    ChallengeEstimate a new parallel task
  18. 18
    ChallengeExplain an unused fast pipeline
  19. 19
    RecapConnect bits, state and time
3

Follow a program from text to execution

13 steps
Read a countdown loop and compare native builds, interpretation and bytecode.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionSeparate the program’s forms
  2. 2
    ExplanationSplit an instruction into fields
  3. 3
    ExplanationName the hardware contract
  4. 4
    ExampleSet up a countdown
  5. 5
    ExampleCount executions, including the exit
  6. 6
    ChallengeChange the start, trace the exit
  7. 7
    ExplanationBuild before running
  8. 8
    ConnectionDecide where library code lives
  9. 9
    ChallengeExplain a successful build with wrong output
  10. 10
    Key InsightInterpretation still runs machine code
  11. 11
    ChallengeMove the program to another CPU
  12. 12
    ChallengeTrace two routes to the same hardware
  13. 13
    RecapKeep each layer’s job clear
4

Compare memory and calculate cache effects

14 steps
Distinguish persistent capacity, storage delays and useful fast copies.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionAsk two questions about stored data
  2. 2
    ExplanationSeparate working and persistent contents
  3. 3
    ExampleRead the capacity unit
  4. 4
    ChallengeLocate the final byte
  5. 5
    ExplanationSeparate waiting from flowing
  6. 6
    ExampleFind one part of a disk delay
  7. 7
    ChallengeMatch the storage behavior
  8. 8
    ExplanationMove down the hierarchy
  9. 9
    ConnectionPredict the next useful bytes
  10. 10
    ExampleInclude both parts of a miss
  11. 11
    ExampleChange the hit rate
  12. 12
    ChallengeCalculate a new cache average
  13. 13
    ChallengeChoose the relevant improvement
  14. 14
    RecapMatch the resource to the need
5

Follow startup, a key press and a save

15 steps
See how OS services, processes and virtual memory connect hardware to an application.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionFollow an editor through the system
  2. 2
    ExplanationRequest a service
  3. 3
    ExampleShare execution time
  4. 4
    ChallengeIdentify the OS boundary
  5. 5
    ExplanationStart before the operating system
  6. 6
    ExampleCreate the running instance
  7. 7
    ExplanationGive memory regions different jobs
  8. 8
    AnalogyUse a private address map
  9. 9
    ChallengeKeep matching addresses separate
  10. 10
    Key InsightStorage can back memory, slowly
  11. 11
    ExampleDeliver the key event
  12. 12
    ExampleSave beyond the process lifetime
  13. 13
    ChallengeSeparate two kinds of slowdown
  14. 14
    ChallengeJoin process protection and saving
  15. 15
    RecapTrace the services in order

How Computers Work practice questions

50 Practice Questions in 5 sets

Set 1: Connections, translation and memory choices10 Practice Questions

Question 1 of 10

A byte-addressable device increases its address width from 12 bits to 14 bits. By what factor does its addressable capacity grow?
  1. 2
  2. 14/12
  3. 4
  4. 16
Show answerHide answer
Answer: C
Each extra address bit doubles the number of possible addresses. Two extra bits therefore multiply the range by four, from 4,096 to 16,384 byte locations. A factor of two counts only one of the added bits; the increase is exponential in the bit count, not proportional to that count.

Question 2 of 10

A sensor samples one channel 24,000 times each second using 12 bits per sample. What is its raw data rate?
  1. 288,000 bits/s
  2. 36,000 bits/s
  3. 2,000 bits/s
  4. 2,304,000 bits/s
Show answerHide answer
Answer: A
Each of the 24,000 samples requires 12 bits, giving 288,000 bits every second. Dividing that result by eight gives 36,000 bytes/s, not 36,000 bits/s. Keep the requested unit attached to the calculation so that converting bits to bytes does not silently change its meaning.

Question 3 of 10

In the teaching machine, JUMPZ 18 is fetched from address 7 while ACC is 4. What address is fetched next?
  1. 7
  2. 18
  3. 4
  4. 8
Show answerHide answer
Answer: D
Fetch first advances PC from 7 to 8. Because ACC is 4, the zero condition is false and execution leaves that next address unchanged. Fetching from 18 would follow the branch even though its condition failed; the presence of a jump operand does not make a conditional branch unconditional.

Question 4 of 10

A task requires 9 billion cycles on a particular CPU running at 3 GHz. Ignoring waiting outside those cycles, how long does it take?
  1. 0.33 s
  2. 3 s
  3. 6 s
  4. 27 s
Show answerHide answer
Answer: B
Three gigahertz provides 3 billion cycles per second, so 9 billion cycles take three seconds. Multiplying the two numbers to obtain 27 uses the rate in the wrong direction. Execution time comes from required cycles divided by cycles available each second.

Question 5 of 10

An 8-bit teaching instruction uses four opcode bits followed by four address bits. ADD is 0010. How is ADD 13 encoded?
  1. 0010 1101
  2. 1101 0010
  3. 0010 1011
  4. 0010 0011
Show answerHide answer
Answer: A
The opcode remains in the first field, and decimal 13 is binary 1101, so the instruction is 0010 1101. Reversing the fields changes the operation as well as the operand. The operand is an address here; encoding it does not require knowing the contents stored at address 13.

Question 6 of 10

A C build has produced machine-code object files but still needs to resolve its library references into an executable. What stage is needed?
  1. Preprocessing
  2. Assembling
  3. Interpreting
  4. Linking
Show answerHide answer
Answer: D
Linking connects object files and the library code or dependencies they require to form an executable. Assembly has already produced the machine-code objects. Repeating assembly does not supply the missing connection between an external function call and the library that implements it.

Question 7 of 10

How many bytes are in 2 KiB?
  1. 2,000 bytes
  2. 256 bytes
  3. 2,048 bytes
  4. 16,384 bytes
Show answerHide answer
Answer: C
The binary prefix Ki means 1,024, so 2 KiB contains 2,048 bytes. Using 2,000 applies the decimal prefix k instead. Multiplying the byte count by eight would give the number of bits, which is a different unit from the bytes requested here.

Question 8 of 10

An archive reads an entire large backup once a year and prioritizes low cost per terabyte. It can tolerate winding to the data. What medium fits those needs?
  1. SRAM cache
  2. Magnetic tape
  3. Main-memory DRAM
  4. A low-capacity optical disc
Show answerHide answer
Answer: B
Magnetic tape suits large, infrequently retrieved backups because it offers low cost per terabyte and the scenario accepts sequential access. A fast cache would solve the wrong problem: it has small capacity, high cost per byte and loses contents without power. Access delay is acceptable here, while persistent bulk capacity is central.

Question 9 of 10

A cache lookup takes 2 ns and RAM takes an additional 80 ns on a miss. The hit rate is 90%. What is the average access time?
  1. 8.2 ns
  2. 9.8 ns
  3. 82 ns
  4. 10 ns
Show answerHide answer
Answer: D
A hit costs 2 ns and a miss costs 82 ns, including the lookup. The weighted average is 0.90×2+0.10×82=10 ns. The tempting 9.8 ns result treats a miss as only 80 ns and omits the cache check that the question explicitly includes.

Question 10 of 10

A computer plays audio while an editor and a browser take turns on one processing stream. What OS function assigns those turns?
  1. File allocation
  2. Device enumeration
  3. Process scheduling
  4. Source-code compilation
Show answerHide answer
Answer: C
The scheduler selects ready work and assigns processor time, allowing several applications to make progress on one stream. Device drivers help communicate with the audio hardware, but assigning turns among all these processes is a scheduling job. Multiple open applications do not require a separate physical core for each.
Set 2: Parts, instructions and everyday computer work10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A thermostat reads a temperature and switches a heater on. What makes it an embedded computer system?
  1. It stores its readings only while the power remains on.
  2. It runs a dedicated control task inside a larger device.
  3. It connects an input device directly to an output device.
  4. It runs the same general-purpose applications as a laptop.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

The CPU writes the value 18 to memory address 92. What belongs on the address bus?
  1. 18
  2. 110
  3. The write command
  4. 92
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A machine reads a package barcode and prints a shipping label. How should these two actions be classified?
  1. Barcode reading is input; label printing is output.
  2. Barcode reading is output; label printing is input.
  3. Barcode reading and label printing are both input.
  4. Barcode reading and label printing are both output.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Two input bits are both 1. What does a two-input XOR gate output?
  1. 1
  2. 10
  3. 0
  4. 11
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What part of the processor performs a subtraction?
  1. The control unit
  2. The ALU
  3. The program counter
  4. The instruction register
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

In the teaching machine, address 8 holds LOAD 30 and address 30 holds 14. PC starts at 8. What are PC and ACC after this instruction executes?
  1. PC is 8; ACC is 14.
  2. PC is 9; ACC is 30.
  3. PC is 9; ACC is 14.
  4. PC is 30; ACC is 14.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A tool converts LOAD, ADD and other assembly mnemonics into binary instructions. What kind of tool is it?
  1. An assembler
  2. An interpreter
  3. A linker
  4. A bootloader
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A 6-byte value starts at byte address 800. What is the address of its final byte?
  1. 806
  2. 804
  3. 848
  4. 805
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

An editor asks to read a file that the user is allowed to open. How does the editor request this protected OS service?
  1. By seizing kernel mode.
  2. Through a system call.
  3. By direct drive commands.
  4. Through its own firmware.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Two separate instances of a program use virtual address 0x3000 for private data. One stores 9 there and the other stores 22. Why can both values remain intact?
  1. Their address spaces can map it to different RAM locations.
  2. The OS keeps both in one physical page and alternates CPU turns.
  3. Each store renumbers the other process’s virtual address.
  4. Both processes share one mapping that keeps the latest value.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Tracing choices and comparing performance10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A program reads a list in address order. After fetching one element, the cache already has several following elements. What property explains this benefit?
  1. Temporal locality
  2. Non-volatility
  3. Spatial locality
  4. Sequential scheduling
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A process reads eight pages. Six are already in RAM and take 60 ns each. Two require an additional 120 µs storage retrieval each, followed by the same 60 ns RAM access. What is the average time per page, ignoring other costs?
  1. 30.06 µs
  2. 30 µs
  3. 120.06 µs
  4. 0.03 µs
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

The teaching machine has LOAD 50, SUB 51, JUMPZ 4, ADD 51, STORE 52, HALT at addresses 0–5. Locations 50 and 51 both hold 6. What is stored at 52 when it halts?
  1. 6
  2. 0
  3. 12
  4. 52
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Two computers have the same CPU and RAM speed. One uses separate instruction and data memories with separate paths. What simultaneous access does that separation allow?
  1. Fetching every instruction of a program.
  2. Saving a file and retaining it without power.
  3. Executing any two dependent instructions.
  4. Fetching an instruction and a data value.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What is the output of (A XOR B) AND (NOT C) when A = 1, B = 1 and C = 0?
  1. 1
  2. 0
  3. 10
  4. 11
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A memory read has placed the selected address in MAR. What register receives the contents returned by memory in the textbook CPU?
  1. MDR
  2. PC
  3. ACC
  4. CIR
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A task takes 18 s on one core: 3 s must remain sequential and 15 s divides evenly among five cores. With no parallel overhead, how long would it take on five cores?
  1. 3.6 s
  2. 3 s
  3. 6 s
  4. 15.6 s
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A teaching loop has LOAD 40, SUB 41, STORE 40, JUMPZ 5, JUMP 0, HALT at addresses 0–5. Location 40 starts at 2 and location 41 holds 1. Starting at PC 0, how many instructions execute through HALT?
  1. 10
  2. 6
  3. 9
  4. 11
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A Java bytecode file runs on two different processor families, each with a suitable JVM. What handles the hardware differences?
  1. A fixed bytecode width replacing the ISA.
  2. A native executable linked into the bytecode.
  3. The OS running bytecode as native code.
  4. The platform-specific JVM implementation.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Two drives have the same sustained transfer rate for a large file. One has much lower random access time. Why can it still open a directory of thousands of tiny files faster?
  1. Tiny files raise the drive’s sustained byte rate.
  2. Each separate read can incur a startup delay.
  3. A lower access time skips all file metadata.
  4. Equal sustained rates give equal opening times.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Diagnosing computer-system behavior10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A faster CPU barely improves a task that repeatedly waits for uncached data from main memory. What change most directly addresses the stated bottleneck?
  1. A cache that captures more of the task’s reused data.
  2. A larger storage drive with unchanged access speed.
  3. A new display with a higher pixel resolution.
  4. A higher clock with unchanged memory waiting time.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A byte-addressable system has 18 address bits and a 32-bit data path. What are its addressable capacity and bytes per transfer?
  1. 32 KiB and 18 bytes.
  2. 256 KiB and 32 bytes.
  3. 256 KiB and 4 bytes.
  4. 1 MiB and 4 bytes.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A storage controller copies a large block into RAM after CPU setup, then signals completion. During the transfer the CPU works on another process. What mechanism explains this?
  1. DMA and repeated CPU polling.
  2. CPU copying and an interrupt.
  3. CPU copying and repeated polling.
  4. DMA followed by an interrupt.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A two-input half adder receives 1 and 1. What are its sum and carry outputs?
  1. Sum 1, carry 0.
  2. Sum 0, carry 1.
  3. Sum 1, carry 1.
  4. Sum 0, carry 0.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

An ideal pipeline has four stages, each taking one cycle. With no stalls, how many cycles complete seven instructions from an empty pipeline?
  1. 7
  2. 10
  3. 28
  4. 11
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A native executable starts on its intended platform but reports that a required shared library is missing. What does this indicate about its library linkage?
  1. It depends on library code supplied separately at runtime.
  2. Its header declarations must be assembled at startup.
  3. Its required library code is entirely copied into the executable.
  4. Its source text is the code being fetched by the CPU.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A 500 GB drive is reported using GiB. Which count is closest to its decimal advertised capacity?
  1. 500 GiB
  2. 512 GiB
  3. 537 GiB
  4. 466 GiB
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A file is kept in cloud storage. Where is its persistent data physically kept?
  1. In the user’s RAM until the next power-off.
  2. Only in the network signals traveling to the user.
  3. On storage equipment in a provider’s data centers.
  4. In the user’s processor cache between sessions.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A cache check takes 3 ns and a miss adds a 60 ns RAM access. Of 200 reads, 150 hit. What is the average read time?
  1. 15 ns
  2. 17.25 ns
  3. 63 ns
  4. 18 ns
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Two user-mode programs share a printer, but only one has permission to print. The printer may later be replaced by a different model. What division of work both enforces access and keeps device commands out of the applications?
  1. The kernel checks access and coordinates jobs; the driver translates device commands.
  2. The driver checks file names; each application directly coordinates the printer’s jobs.
  3. The kernel translates model-specific commands; each application grants its own access.
  4. The printer chooses user permissions; the scheduler translates the printer’s commands.
Show answerHide answer

Save this lesson to see this answer.

Set 5: Connecting instructions, memory and the operating system10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An ALU subtraction gives zero. A following conditional branch tests whether that result was zero. What stored CPU information supports the decision?
  1. The clock pulse count.
  2. The zero status flag.
  3. The operand’s address.
  4. The data bus width.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

An interrupt is accepted after an instruction finishes, when the next PC is 26 and ACC is 17. The handler uses ACC. What state is needed to resume the interrupted calculation correctly?
  1. The completed instruction’s address and handler registers.
  2. The next instruction address and the handler’s registers.
  3. The saved next PC and the original working registers.
  4. The program’s start address and initial register values.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

On one core a task takes 16 s. Twelve seconds can run in parallel and four seconds cannot. Ignoring overhead, what improvement occurs when moving from four to six cores?
  1. It falls from 7 s to 6 s.
  2. It falls from 4 s to 2.67 s.
  3. It falls from 7 s to 4.67 s.
  4. It falls from 12 s to 8 s.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A CPU uses an 8-bit format with four opcode bits and four direct-address bits. Why can that unchanged format not directly encode LOAD 19?
  1. The address fits if the opcode shrinks in the same format.
  2. A LOAD operand always uses the full instruction width.
  3. A 64-bit host CPU extends every teaching operand.
  4. The direct-address field can name only 0 through 15.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A developer edits a C source file and compiles it into an updated object file, but skips linking. The old executable is launched, and its shared libraries are unchanged. What build step remains, and why does the old behavior persist?
  1. Reprocess the headers; launching an old executable automatically incorporates new objects.
  2. Reassemble the old executable; its instruction encodings change when the source is edited.
  3. Relink the updated object; the old executable still has the earlier program instructions.
  4. Reload the shared libraries; their instructions replace all changed object-file instructions.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A user saves a document and then shuts down normally. Which location keeps the saved document without power?
  1. The SSD or other non-volatile storage.
  2. The CPU’s accumulator until the next startup.
  3. The DRAM cells that held the open document.
  4. The SRAM cache used by the editor process.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

Two caches both take 2 ns to check. A miss adds 100 ns. One hits on 92% of reads; the other on 96%. What happens to average access time?
  1. It falls from 9.84 ns to 5.92 ns.
  2. It falls from 8 ns to 4 ns.
  3. It falls by 4% from 10 ns.
  4. It falls from 10 ns to 6 ns.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A control task spends 1 ms on a fixed sequential step and 6 ms on work that divides perfectly among three cores. A real-time requirement is a 4 ms deadline. Ignoring overhead, what ideal runtime and deadline result follow?
  1. 3 ms, meeting the deadline.
  2. About 2.33 ms, meeting the deadline.
  3. 4 ms, meeting the deadline.
  4. 7 ms, missing the deadline.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A process repeatedly acquires heap memory it no longer needs and never releases it. Later, frequent page transfers to storage dominate its runtime. What sequence explains the slowdown?
  1. A stack overflow keeps old heap blocks and swapping causes thrashing.
  2. A memory leak raises demand and heavy swapping causes thrashing.
  3. A memory leak raises demand, but page transfers are fast cache lookups.
  4. A memory leak enlarges saved files while RAM demand stays unchanged.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A PC reports that firmware startup checks completed, reaches a bootloader menu, then reports a missing kernel image. After power cycling, firmware setup still opens. What explains both the completed startup stage and the available setup screen?
  1. The kernel initialized its drivers but failed to start the bootloader; firmware stays in RAM.
  2. The bootloader completed kernel loading; firmware setup runs from the previous process’s RAM.
  3. The kernel reached user mode before loading; the bootloader recreates firmware after power-off.
  4. The bootloader ran but did not load the kernel; persistent firmware can still execute.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

109 Key Terms, each with its definition

A

Access time and transfer rate
Access time is the delay until data begins arriving, while transfer rate is the amount delivered per second once transfer is underway.
Thousands of tiny files pay repeated access delays, while one large file emphasizes sustained transfer rate.
Accumulator
An accumulator is a working register that holds arithmetic or logic results and supplies operands in a simple processor design.
In a simple accumulator machine, ADD updates ACC, while STORE copies ACC to memory without changing its value.
Address bus
The address bus carries the location selected for a memory or device access, identifying where the transferred contents belong.
During a CPU write to address 300, the address bus carries 300 while the data bus carries the value.
Analog-to-digital converter
An analog-to-digital converter samples an analog signal and represents the measured values as digital numbers for computer processing.
A microphone’s input circuitry converts sound measurements into numbers stored as an audio recording.
AND gate
An AND gate outputs 1 only when all its input bits are 1; any input of 0 makes its output 0.
A two-input AND produces a carry bit when a half adder receives two input bits that are both 1.
Arithmetic logic unit
The arithmetic logic unit is CPU circuitry that performs arithmetic, bitwise logic, shifts and comparisons and records result conditions.
Subtracting a value from itself produces zero, which the ALU can record for a following conditional branch.
Assembler
An assembler translates assembly-language instructions into their machine-code encodings for the selected instruction set architecture.
The mnemonic for an addition becomes the binary instruction that the target CPU can fetch and execute.
Assembly language
Assembly language represents machine instructions with readable mnemonics, register names and labels tied closely to a particular ISA.
A countdown written with LOAD, SUB and jumps exposes the operations that implement its loop.

B

Bandwidth
Bandwidth is the quantity of data a communication path can transfer per second, often expressed in bytes per second or bits per second.
A wider path can move more bytes per transfer, increasing bandwidth when the transfer rate is fixed.
Bootloader
A bootloader is startup software that loads the operating-system kernel from storage into memory and transfers execution to it.
After firmware prepares the hardware, the bootloader brings the kernel into RAM so OS startup can continue.
Branch
A branch is an instruction that changes the next instruction address, either unconditionally or only when a stated test succeeds.
A jump-if-zero instruction such as JUMPZ sends a CPU to its target only when the accumulator is zero at execution.
Bus
A bus is a shared communication path that carries signals between computer components; a parallel bus carries several bits at once.
A classic system bus lets the processor send a memory address and receive the contents stored there.
Byte-addressable memory
Byte-addressable memory assigns a distinct address to each byte, so a multi-byte value occupies several consecutive address locations.
A four-byte value starting at 1000 occupies addresses 1000 through 1003, leaving 1004 as the next location.
Bytecode
Bytecode is an instruction representation for a virtual machine, allowing a program to be distributed independently of a particular physical CPU.
A Java bytecode file can run through different JVM implementations on ARM and x86-64 computers.

C

Cache
A CPU cache is a small, fast SRAM store holding copies of instruction and data blocks from slower memory levels for quick reuse.
A loop can repeatedly find its instructions in cache instead of fetching them from RAM each time.
Cache hit and miss
A cache hit finds requested contents in the cache; a miss requires retrieving them from a slower level, adding delay to that access.
A miss for a list element can load its neighboring bytes too, making later accesses hit in the cache.
Cache line
A cache line is the block of neighboring memory bytes moved into a CPU cache together, commonly 64 bytes in modern processors.
Fetching one requested byte can also copy nearby bytes that later reads will find without another RAM access.
Clock cycle
A clock cycle is one timing interval in the processor’s clock signal, coordinating circuit changes without necessarily completing an instruction.
A 3 GHz clock gives about 0.33 ns per cycle, while an instruction may involve several internal steps.
Clock speed
Clock speed is the rate of processor timing cycles, measured in hertz; it influences execution time together with the work done per cycle.
A fixed six-billion-cycle task takes 1.5 s at 4 GHz, but different CPU designs may require different cycle counts.
Cloud storage
Cloud storage is a service that keeps files on a provider’s physical storage equipment and makes them accessible through a network.
A remote file can be shared across devices, but reading it depends on the connection and provider.
Compiler
A compiler translates program code into another representation, often machine code or bytecode, either ahead of time or during execution.
An ahead-of-time compiler can turn a C program into code for the processor selected as its target.
Control bus
The control bus carries command and timing signals that coordinate transfers, including read, write and interrupt-request signals.
A write signal tells memory to store the data-bus contents at the location selected by the address bus.
Control unit
The control unit coordinates instruction execution by fetching and decoding instructions and issuing signals to the processor’s other parts.
For an ADD instruction, the control unit selects operands while the ALU performs the addition itself.
Core
A core is a processing unit with the control, arithmetic and working-state resources needed to execute an instruction stream.
Four cores can execute separate work at the same time when the operating system has ready tasks.
Current instruction register
The current instruction register holds the fetched instruction while it is decoded and executed; instruction register is another name.
After an instruction arrives in MDR, a CPU copies it to CIR so its operation can be decoded.

D

Data bus
The data bus carries instructions or values being transferred between the processor, memory and devices, supporting reads and writes.
A memory read returns a stored byte over the data bus after its location has been selected.
Device controller
A device controller is hardware that handles low-level device communication and provides status and data registers for the system.
A storage controller receives a transfer request and reports when its block of data has reached RAM.
Device driver
A device driver is software that translates general operating-system requests into the commands needed by a particular device controller.
A printer driver turns the OS’s print request into commands that the connected printer understands.
Digital-to-analog converter
A digital-to-analog converter turns digitally represented values into an analog signal that can drive an output such as a speaker.
Playing a stored recording requires converting its digital samples into a signal for the speaker.
Direct memory access
Direct memory access lets a device or DMA controller transfer blocks to or from RAM without the CPU copying each individual byte.
After setting up DMA for an image transfer, the CPU can run other work while the block moves.
DRAM
DRAM is volatile memory that stores bits as charge in capacitors and requires regular refresh, making it suitable for large main memory.
Refreshing DRAM restores charge before leakage makes the stored bit values unreliable during operation.

E

Embedded system
An embedded system is a computer built into a larger device to perform a dedicated task using its processor, memory and input/output.
A washing machine’s controller reads sensors and switches its motor through a stored control program.
Executable
An executable is a program file prepared for loading and running, containing code and supporting information in a platform’s expected format.
A native executable can depend on both its target processor’s ISA and its operating system’s file format.

F

Fetch-decode-execute cycle
The fetch-decode-execute cycle is the repeated process of obtaining a machine instruction, interpreting its operation and carrying it out.
A LOAD instruction first has to be fetched before its execution performs the separate data read.
File system
A file system organizes stored contents into named files and folders and tracks their locations, sizes, dates and access permissions.
The path /home/sam/notes.txt identifies a Linux file without revealing which storage blocks contain it.
Firmware
Firmware is low-level software stored in non-volatile memory that controls hardware or supplies startup instructions before the main OS runs.
UEFI firmware prepares a PC’s hardware and starts a bootloader before the kernel is loaded into RAM.
Flip-flop
A flip-flop is a clocked storage circuit that captures a bit at a clock edge and holds that state between updates.
Rows of flip-flops can hold register values and update together at the appropriate clock edge.

G

Graphics processing unit
A graphics processing unit is a processor specialized for highly parallel work that applies similar operations to many data values.
Updating many image pixels suits GPU processing because the work contains many similar calculations.
GUI and CLI
A GUI provides visual controls such as windows and icons; a CLI accepts typed commands that can also be combined in scripts.
A user can browse a folder visually or use ls in a command line to request its file listing.

H

Half adder
A half adder adds two input bits and produces separate sum and carry bits, using XOR for the sum and AND for the carry.
Adding two 1 bits produces carry 1 and sum 0, representing the two-bit binary number 10.
Hard disk drive
A hard disk drive stores bits magnetically on rotating platters, using a moving head that introduces seek and rotational delays.
Reading scattered small files makes an HDD repeatedly pay delays before transferring each block.
Hardware
Hardware is the physical equipment in a computer system, including its processor, circuit boards, memory chips, drives and devices.
A laptop’s keyboard and RAM modules are hardware, while the text editor running on it is software.
Harvard architecture
The Harvard architecture keeps instructions and data in separate memories with separate paths, enabling one access of each kind together.
A microcontroller can fetch its next instruction while reading a sensor value through its data path.
Heap
The heap is a process memory region used for allocations requested during execution, such as storage for a collection that grows.
A program building a variable-size list can obtain heap memory as it receives additional elements.
Hit rate
The hit rate is the number of accesses found in a cache divided by the total accesses, expressing how often the fast copy is available.
A cache finding 950 of 1,000 requested values has a 95% hit rate and a 5% miss rate.

I

Input device
An input device supplies data to a computer, including data entered by a person or measurements collected from the physical world.
A light sensor provides input that a controller uses to decide whether a lamp should switch on.
Instruction set architecture
An instruction set architecture defines a processor’s instructions, encodings and registers, establishing its machine-code software interface.
A native build for ARM targets a different ISA from a native x86-64 build of the same source program.
Interpreter
An interpreter is a program that carries out another program’s operations during execution, using its own implementation on the host computer.
The CPU runs an interpreter’s machine code while it implements the operations of a high-level program.
Interrupt
An interrupt is a signal requesting processor attention, causing an appropriate handler to run before interrupted work resumes.
A completed disk transfer can raise an interrupt so the OS knows the requested data is ready.
Interrupt handler
An interrupt handler is a routine that responds to an interrupt while the interrupted program’s state is preserved for later resumption.
A keyboard handler helps process a key event, after which the interrupted calculation can continue.

J

Just-in-time compilation
Just-in-time compilation translates code into native machine instructions while the program runs, often focusing on frequently executed parts.
After identifying a hot loop, a runtime can compile it so later repetitions avoid repeated interpretation.

K

Kernel
The kernel is the core of an operating system that controls privileged resources and enforces the protected boundary around applications.
A user-mode application requests kernel file services instead of issuing unrestricted drive commands itself.

L

Latch
A latch is a feedback circuit that can retain one bit while powered, forming a simple building block for storing digital state.
Cross-coupled gates feed their outputs back into one another so the circuit can remember its state.
Linker
A linker combines object files and resolves library references to produce an executable, using static code or shared-library dependencies.
An unresolved external function after assembly requires linking work, not another pass over the source syntax.
Logic gate
A logic gate is a circuit that takes one or more input bits and produces an output bit according to a fixed rule such as AND or NOT.
Combining gates lets a processor compare bit patterns, calculate sums and control where results go.

M

Machine code
Machine code is the binary encoding of instructions that a processor executes directly according to its instruction set architecture.
An x86-64 executable contains instruction encodings that an ARM processor cannot execute natively.
Magnetic tape
Magnetic tape is a persistent storage medium that records data along a sequence, offering low-cost bulk capacity with slow positional access.
A large archive can accept the winding delay needed to retrieve data that is accessed only occasionally.
Memory address register
The memory address register holds the location selected for a memory read or write, supplying the address side of the access.
To read a data value from location 20, a CPU puts 20 in MAR before requesting the read.
Memory data register
The memory data register holds contents just read from memory or about to be written; it is also called the memory buffer register.
During STORE, MDR receives the accumulator’s value before that value is written to the selected location.
Memory hierarchy
The memory hierarchy combines small, fast stores near the CPU with larger, slower levels, balancing capacity, speed and cost per byte.
Registers and caches serve immediate work, while RAM, drives and archives provide progressively larger stores.
Memory leak
A memory leak is retained memory that a program no longer needs but fails to release, allowing unnecessary allocation to accumulate.
A long-running program that repeatedly abandons unneeded heap allocations can steadily increase its memory use.
Memory management unit
The memory management unit is CPU hardware that translates virtual addresses using OS-established mappings and checks access permissions.
An access to a protected location faults when the process’s mapping does not allow the requested operation.
Moore’s law
Moore’s law is the historical observation that chip transistor counts grew at roughly a doubling every two years over a long period.
More transistors can provide larger caches and additional cores without doubling the speed of every program.

N

NAND gate
A NAND gate reverses the AND result, outputting 0 only when all inputs are 1; NAND gates alone can implement any logic function.
Connecting both inputs of a NAND gate to one bit makes its output the opposite of that bit.
NOR gate
A NOR gate reverses the OR result, outputting 1 only when every input is 0; NOR gates alone can implement any logic function.
When either of two inputs is 1, their NOR output is 0 because their OR result would be 1.
NOT gate
A NOT gate reverses its single input bit, outputting 1 for an input of 0 and outputting 0 for an input of 1.
If a signal entering a NOT gate is 0, the next connected gate receives 1 from its output.

O

Opcode
An opcode is the part of a machine instruction that specifies its operation, such as loading a value, adding or branching.
In an instruction encoding, changing the opcode can change a data load into a different operation.
Operand
An operand supplies an instruction’s input or destination, such as a register, an address or an immediate value, as defined by the instruction.
In an instruction such as LOAD 10, the operand is address 10, whose contents are read into the accumulator, ACC.
Operating system
An operating system manages hardware resources and supplies services that applications use to run, access files and communicate with devices.
An editor requests a file by name while the OS locates its data and coordinates the storage device.
Optical disc
An optical disc stores data as marks read by a laser from a reflective layer, providing removable media such as CDs, DVDs and Blu-ray discs.
A single-layer DVD typically stores 4.7 GB, while a single-layer Blu-ray disc typically stores 25 GB.
OR gate
An OR gate outputs 1 when at least one input is 1, including the case in which every input is 1.
Two input 1s keep an OR output at 1; interpreting this as "one but not both" would confuse it with XOR.
Output device
An output device presents a computer’s results or acts on them physically, such as by displaying an image or moving an actuator.
A valve is an output device when a controller opens it in response to a measured temperature.

P

Page
A page is a fixed-size block used in virtual-memory mappings and movement of contents between RAM and backing storage.
A system using 4 KiB pages maps and retrieves memory in blocks containing 4,096 bytes each.
Pipelining
Pipelining overlaps stages of different instructions, increasing the rate at which instructions finish once the pipeline is filled.
While one instruction executes, another can decode and a third can fetch in a three-stage pipeline.
Polling
Polling is the repeated checking of a device’s status to find out whether it has data ready or has completed an assigned operation.
A processor checking an idle sensor again and again spends time on checks that return no new data.
Process
A process is a running instance of a program with its own execution state, address space and resources managed by the operating system.
Separate editor instances can use the same program file while keeping different document state in memory.
Program counter
The program counter holds the address of the next instruction to fetch, advancing during fetch and changing when a branch is taken.
A jump back to address 0 replaces PC’s sequential next address so the program can repeat a loop.

R

RAM
RAM is read/write working memory with direct access to locations; ordinary computer RAM is volatile and holds running instructions and data.
An editor keeps current document contents in RAM, while a saved copy resides on non-volatile storage.
Real-time operating system
A real-time operating system provides specified response-time guarantees for tasks whose correctness depends on meeting deadlines.
An industrial control response must arrive before its deadline, even if a later response would compute the same value.
Register
A register is a small, very fast storage location inside the processor that holds an immediate working value, address or instruction.
Keeping a loop counter in a register avoids repeatedly retrieving that working value from main memory.
RISC and CISC
RISC and CISC are instruction-set design styles favoring regular simple operations and more complex operations, respectively.
RISC-V’s compressed forms show why identifying a RISC design does not establish one instruction length.
ROM
ROM is non-volatile memory associated with retained, normally fixed contents; modern firmware commonly uses updateable flash instead.
Calling a phone’s frequently written file space "ROM" confuses its flash storage with fixed startup contents.

S

Scheduler
The scheduler is the OS component that selects ready work for processor time, sharing available execution resources among processes.
Short turns allow a music player and editor to keep progressing on a single processing stream.
Secondary storage
Secondary storage keeps programs and data without power, offering persistent capacity accessed more slowly than working main memory.
An application file stays on the SSD after its running process ends and its RAM is reclaimed.
Software
Software consists of programs and the data they work with, providing the instructions and information that give hardware useful tasks.
An image editor uses software instructions to change the color values stored for a photograph.
Solid-state drive
A solid-state drive uses non-volatile flash cells without moving parts, providing fast random access to persistent programs and files.
An SSD suits a laptop’s active files because fast access and shock resistance help during portable use.
Source code
Source code is the human-readable text of a program, written in a programming language before translation or interpretation.
Editing a C source file changes its text, but the earlier native executable remains unchanged until rebuilt.
Spatial locality
Spatial locality is the tendency to access addresses near a recently used address, making copies of neighboring bytes useful.
Reading consecutive list elements benefits when one cache-line fetch brings several of them nearby.
SRAM
SRAM is volatile memory that holds bits in latch-style circuits without refresh while powered, providing fast but costly storage per bit.
CPU caches use SRAM to reduce access delays even though it costs more per byte than main-memory DRAM.
Stack
The stack is a process memory region tracking active function calls, including return addresses and local values needed by those calls.
A function call adds its working information, and returning releases that call’s portion of the stack.
Stack overflow
A stack overflow occurs when call-stack demands exceed the available stack space, often after function calls repeat without a stopping point.
A function that keeps calling itself adds call records until the process runs out of available stack space.
Static and dynamic linking
Static linking copies needed library code into an executable; dynamic linking connects it to separately supplied shared libraries.
A dynamically linked program may fail to start if a required compatible shared library is missing.
Status flag
A status flag is a stored CPU condition set by an operation, such as a zero or negative result, that a later instruction can test.
A conditional branch can check the zero flag to decide whether to continue or jump to another address.
Stored-program concept
The stored-program concept means that instructions are represented as binary contents in memory for a processor to fetch and execute.
Loading a different program lets the same computer edit a document after it has played a game.
Swapping
Swapping moves memory pages between RAM and storage backing, allowing inactive contents to leave RAM so other work can use the space.
A page kept in a swap file must be retrieved before its missing contents can be used again in RAM.
System call
A system call is a controlled request from a program to the operating-system kernel for a protected service such as file or device access.
The kernel can check the user’s file permission before carrying out an application’s read request.
System on a chip
A system on a chip combines several computer functions, such as CPU, graphics and device-control circuitry, within one integrated chip.
A phone uses a system on a chip to fit many computing functions into a small, power-efficient device.

T

Temporal locality
Temporal locality is the tendency for recently used instructions or data to be accessed again soon, making retained copies useful.
A loop repeatedly reads and updates its counter, reusing the same working contents over a short time.
Thermal throttling
Thermal throttling is the reduction of processor clock speed when temperature is too high, protecting the chip while reducing its work rate.
A long-running calculation can slow when cooling cannot remove the heat produced at its earlier clock rate.
Thrashing
Thrashing is severe slowdown caused when frequent movement of pages between RAM and storage consumes much of the system’s execution time.
Closing memory-heavy applications can reduce page traffic and leave more RAM for the remaining active work.
Transistor
A transistor is an electronically controlled component that acts as a switch in digital circuits, helping represent and manipulate bits.
Groups of transistors implement the gate rules used inside an arithmetic logic unit and its registers.
Truth table
A truth table lists a circuit’s output for every possible combination of its inputs, making the complete input/output rule explicit.
A two-input gate needs four rows because its two bits have four possible input combinations.

V

Virtual machine
A language virtual machine is software that provides the instruction environment needed to execute bytecode on a physical computer.
The JVM interprets or compiles Java bytecode using an implementation built for the host platform.
Virtual memory
Virtual memory gives processes their own address spaces, mapping their addresses to physical memory while enforcing access permissions.
Two processes can use the same written virtual address while keeping their private values in different RAM pages.
Von Neumann architecture
The von Neumann architecture places program instructions and data in one main memory connected to a processor and input/output devices.
An instruction fetch and a data read compete for the shared memory path in the classic design.

W

Wear leveling
Wear leveling is a flash-controller technique that spreads erase/write operations across cells to distribute their limited write endurance.
Redirecting repeated writes across cells helps avoid wearing out one frequently updated region early.
Word
A word is the natural size of data a processor handles in one operation, commonly reflected in its general-purpose register width.
A 64-bit word fits eight bytes, but that does not require every connection to use 64 parallel wires.
Write-back
Write-back is the stage in an instruction’s execution that places a computed result into its destination register or memory location.
After an arithmetic operation, writing the result into its destination makes it available to later instructions.

X

XOR gate
A two-input XOR gate outputs 1 when its inputs differ and 0 when they are equal, implementing the sum-bit rule of a half adder.
A half adder receiving 1 and 1 has a zero sum bit from XOR and a carry bit from AND.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started