09 — How Computers and Systems Work

A progressive guide to how processors, memory, storage, operating systems, processes, and networks cooperate to make computer systems work.

The Computer as a System

A computer is best understood as a system of cooperating components rather than as a single device. It represents information, executes instructions, stores data, and communicates with other systems.

The main roles fit together as follows:

  • The executes instructions and performs calculations.

  • Main memory holds programs and data currently in use.

  • Persistent storage retains programs and data when power is removed.

  • Input/output devices exchange information with users and other equipment.

  • The operating system coordinates hardware and provides services to applications.

  • Network interfaces and protocols allow computers to exchange data.

Hardware performs physical operations. Software consists of instructions and data that direct those operations. When a user opens a document, the operating system locates it in storage, copies needed data into memory, schedules time for the application, and sends output to the display.

This layered view is useful: applications request services from the operating system; the operating system manages hardware; and hardware interacts with networks and the physical environment.

Takeaway: Everyday computer actions result from cooperation among software, the operating system, hardware, and connected systems.

and Representation

describes how a computer’s components are arranged and how they cooperate. A typical general-purpose computer includes a system board, one or more processing cores, main memory, persistent storage, device controllers, interfaces, a power system, clocking circuitry, and buses or high-speed interconnects.

The normally does not operate directly on files stored on an SSD or HDD. Programs and data are first transferred into main memory, where the can access them as addressed locations. Main memory is faster than persistent storage but loses its contents when power is removed.

Computers represent information with bits. A byte contains eight bits, and larger values may be grouped into words. An address identifies a location in memory or an input/output resource. If a uses nn address bits, it can theoretically represent up to 2n2^n distinct addresses, although hardware and operating-system limits may be lower.

Memory addresses and storage locations are related but not identical. A maps human-readable file names to blocks on persistent storage, while the operating system and memory-management hardware map program addresses to locations in main memory.

Takeaway: Organization explains both what components a computer contains and how information moves among them.

Processors and Instruction Execution

A repeatedly carries out a sequence of steps often called the instruction cycle:

  1. Fetch: Obtain the next instruction from memory.

  2. Decode: Determine what operation the instruction requests.

  3. Execute: Perform the operation using circuits.

  4. Retire or write back: Record the result and update state.

Important components have specialized roles:

  • Registers provide very small, very fast storage inside the .

  • Arithmetic and logic units perform arithmetic, comparisons, and Boolean operations.

  • Control logic directs instruction execution.

  • The instruction decoder interprets binary instruction encodings.

  • The program counter holds the address of the next instruction.

  • A status or flags register records conditions such as zero, carry, or overflow.

  • A cache keeps recently used instructions and data close to the .

An defines the programmer-visible behavior of a , including its instructions, registers, data types, memory-addressing rules, encodings, and exception behavior. High-level languages such as Python, Java, and C are translated into machine instructions or executed through an interpreter or virtual machine.

An interrupt requests attention, often from a device or timer. An exception is caused by the currently executing instruction, such as division by zero or an invalid memory access. The saves execution state and transfers control to a handler, usually supplied by the operating system.

Takeaway: The executes encoded instructions through a controlled cycle, while interrupts and exceptions temporarily redirect that execution when attention is needed.

The Memory Hierarchy

The memory hierarchy places storage levels in an order based on speed, capacity, and cost per byte. Storage closer to the is generally faster, smaller, and more expensive per byte.

A typical hierarchy is:

  1. registers

  2. L1 cache

  3. L2 and L3 caches

  4. Main memory, or RAM

  5. SSD or HDD storage

  6. Network or archival storage

A occurs when requested information is already in a cache. A cache miss requires retrieval from a slower level. Programs often benefit from locality of reference, meaning that they reuse the same data or access nearby instructions and data. For example, processing adjacent elements of an array can benefit from caching.

gives each a virtual address space. The ’s memory-management unit translates virtual addresses into physical memory locations. This arrangement provides:

  • Isolation between processes.

  • Protection of operating-system memory.

  • A consistent address space for programs.

  • The ability to move inactive memory pages to storage when necessary.

Memory is commonly divided into fixed-size pages. A page fault occurs when a referenced page is not available in the required physical-memory location. The operating system must then load or reconstruct it, which is much slower than an ordinary memory access. does not replace physical RAM; excessive movement of pages between RAM and storage can leave the system spending more time managing memory than running applications.

Takeaway: The hierarchy improves performance by keeping frequently used information close to the , while provides protection and flexible address management.

Persistent Storage and Files

Persistent storage retains data without continuous power. Common forms include:

  • HDDs, which store data magnetically on rotating platters and use moving mechanical parts.

  • SSDs, which store data in nonvolatile flash memory and have no moving read/write heads.

  • Removable flash media, such as memory cards and USB drives.

  • Network storage, which allows several computers to access shared storage.

SSDs generally provide lower access latency and better resistance to mechanical shock than HDDs. HDDs can provide large capacities at comparatively low cost. Both differ from RAM: RAM holds data actively being used, while persistent storage retains data for later use.

A organizes persistent storage into files and directories. It typically records file names and paths, contents, sizes, ownership, permissions, timestamps, and the storage blocks containing data.

When an application saves a document, it asks the operating system to write data to a file. The operating system and file-system driver translate that request into operations on storage blocks. When the document is opened later, the reverse retrieves the blocks and presents the data as a file.

Takeaway: Storage preserves information over time, and the gives applications an organized way to name, protect, locate, read, and write that information.

Operating Systems and Resource Management

An manages hardware and provides common services to applications. Its major responsibilities include scheduling, memory management, file and storage access, device control, security, and communication.

Important operating-system components include:

  • The kernel, which is the privileged core that controls hardware and essential resources.

  • The and manager, which creates, schedules, pauses, and terminates execution units.

  • The memory manager, which allocates memory, maintains virtual-address mappings, and enforces protection.

  • The file-system manager, which provides files, directories, permissions, and storage access.

  • Device drivers, which translate general operating-system requests into device-specific operations.

  • The networking stack, which implements network protocols and communication interfaces.

  • A user interface, which may be graphical, command-line based, or embedded in another program.

Applications normally run in user mode with restricted access. The kernel runs in privileged mode and can access protected instructions and hardware resources. An application requests an operating-system service through a system call, such as opening a file, creating a , allocating memory, or sending network data.

During booting, firmware initializes hardware and locates a bootable device. A bootloader loads the kernel and supporting components into memory. The kernel then initializes drivers and services, creates initial processes, and makes the system available to users and applications.

Takeaway: The operating system is the coordinating layer that turns application requests into controlled operations on hardware.

Processes, Threads, and Scheduling

A program is a passive collection of instructions and data. A is a running instance of a program together with resources such as a virtual address space, open files, security information, and at least one .

A is an independently schedulable sequence of instructions within a . Threads in one share its address space and many resources, but each has its own execution state, registers, and stack. A browser, for example, may use separate threads for the user interface, networking, rendering, media, and background work.

The scheduler chooses which ready should run on which core. On a single core, the operating system creates the appearance of simultaneous execution by rapidly switching among threads. A context switch saves one ’s state and restores another’s. On a multicore , several threads may execute truly concurrently.

Concurrent threads must coordinate access to shared data. Poor synchronization can cause:

  • Race conditions, where the result depends on timing.

  • Deadlocks, where threads wait indefinitely for one another.

  • Starvation, where a repeatedly fails to receive needed resources.

More threads do not automatically make a program faster. creation, communication, synchronization, and context switching all have costs.

Takeaway: Processes provide resource and protection boundaries, threads provide schedulable execution, and the operating system balances responsiveness with coordination costs.

Networks, Packets, and Protocol Layers

A computer network is a collection of connected devices that exchange data according to agreed rules called protocols. Common components include network interfaces, switches, routers, and wireless access points.

Data sent across a network is divided into formatted units called a . A normally contains a payload plus control information such as source and destination addresses, sequencing information, and error-detection data.

An IP address identifies a network interface at the Internet Protocol layer. Routers examine destination IP addresses and choose a next hop. A port number identifies an application service on a host, allowing many networked applications to share one IP address.

Networking is commonly described in layers:

  1. The link layer moves frames across a local connection such as Ethernet or Wi-Fi.

  2. The Internet layer uses IP addresses to move packets between networks.

  3. The transport layer provides communication between application processes.

  4. The application layer defines services such as web requests, file transfer, and name lookup.

is connection-oriented and provides a reliable, in-order byte stream. It uses sequence numbers, acknowledgments, checksums, and retransmission to detect and recover from lost data. UDP is connectionless and has less built-in overhead, making it useful when an application prefers low delay or can handle loss itself.

When a web address is entered, name resolution finds an IP address for the domain. The operating system assigns data to a transport protocol and destination port, the network interface sends local frames, and routers forward packets toward the destination. The server passes received transport data to the web , and the response returns to the browser.

Takeaway: Layered protocols let application processes communicate across different networks while separating local delivery, routing, transport, and application responsibilities.

Putting the System Together

Consider a user editing and saving a photograph. The action brings together nearly every major part of a computer system:

  1. The operating system starts the image editor as a .

  2. The program’s instructions and the photograph move from persistent storage into RAM.

  3. The fetches instructions and data, using registers and caches to reduce access time.

  4. The scheduler gives the editor’s threads time.

  5. The editor requests keyboard or mouse input through the operating system.

  6. The editor modifies image data in memory.

  7. The save operation invokes file-system and storage services.

  8. The operating system writes the updated data to an SSD or HDD.

  9. If the photograph is uploaded, the networking stack divides the data into packets and sends them through a network interface.

The same pattern appears when loading a web page: an application requests a service, the operating system coordinates resources, the executes instructions, memory holds active data, storage supplies persistent data, and network components exchange packets.

The important connection is that no single component performs the whole task. Each component contributes a specific capability, and the operating system coordinates their interaction.

Final takeaway: Computer systems work because processors, memory, storage, devices, operating-system services, processes, threads, and networks form a coordinated chain from user action to physical operation and back again.