MCA · MCA C1001
The computer system: components, software, and execution
Explore CPU and memory organisation, operating-system boundaries, program execution, processes, threads, interrupts, and DMA.
On this page
This chapter develops the machinery introduced in Introduction to computers. It teaches the essential system model here; later units examine architecture, memory technologies, and operating systems in more detail.
What you will learn
Identify processor, memory, storage, and input/output roles; trace a stored program; distinguish software, firmware, processes, and threads; explain locality, interrupts, and DMA.
1. The computer system and its components
| Component | Main role | Example question |
|---|---|---|
| Processor | Executes instructions and coordinates operations | Which operation should run next? |
| Main memory | Holds working instructions and data | What values are needed during this execution? |
| Persistent storage | Retains files and other durable data | What should remain after the application closes? |
| Input/output subsystem | Transfers data between the system and its environment | How does a key press reach the application? |
| Interconnects and controllers | Carry transfers and coordinate access to devices | How does the processor communicate with memory and devices? |
Inside the processor
The arithmetic and logic unit (ALU) performs operations such as addition and comparisons. Control logic interprets instructions and coordinates their execution. Registers retain small amounts of state close to the execution units, including operands and control information. Modern processors also contain caches and specialised execution units.
This functional description is deliberately simplified. Not every arithmetic operation uses one identical ALU, and actual processors may pipeline operations, predict branches, or execute instructions out of order while preserving the required architectural behaviour.
Memory is not the same as storage
Ordinary DRAM used as main memory is volatile: it normally needs power to retain contents. SSDs and hard drives retain data without continuous power. Registers, caches, main memory, and persistent storage have different capacities, costs, and access characteristics.
When an application loads a document, it may read the file from storage into memory. Editing the in-memory copy does not guarantee that changes have been saved. Closing an application before saving can lose those changes; a correctly designed autosave system changes this behaviour.
Addresses, values, and the memory model
An address identifies a location in an address space; the contents are the value stored there. The number on a locker identifies the locker, not what it contains. Similarly, changing a memory value does not necessarily change its address. A variable is a program-level name; the implementation decides how its value is represented and where it lives.
In a simple byte-addressed model, consecutive addresses identify consecutive bytes. A multi-byte value occupies more than one byte, so the implementation must know its size and byte order. Do not assume every abstract instruction or hardware device uses exactly the same addressable unit.
| Address | Contents | Possible interpretation |
|---|---|---|
| 1000 | 01000001 | ASCII A, or unsigned integer 65 |
| 1001 | 00000101 | Unsigned integer 5 |
| 1002 | 00000000 | Integer zero, or a terminator under a chosen convention |
A real application normally uses virtual addresses managed through the OS and processor’s memory mechanisms. A virtual address need not equal a physical memory location. Virtual memory provides an abstraction; it does not create unlimited RAM. Detailed address translation belongs to later operating-system study.
Why memory is a hierarchy
Fast storage close to execution units is expensive in capacity and implementation resources. Large storage has different access costs. Systems combine levels to obtain useful capacity and speed at an acceptable cost. Registers serve immediate instruction needs; caches retain likely reusable data; main memory supports working state; persistent storage holds durable files.
Temporal locality means recently used data or instructions are likely to be used again. A loop repeatedly accessing a counter is an example. Spatial locality means nearby locations are likely to be used together. Sequentially reading an array is an example. A cache exploits these patterns, but it cannot guarantee a hit for every access.
Consider reading ten consecutive array elements versus following ten pointers to widely separated locations. Both perform ten logical reads; their memory-system behaviour can differ. This explains why counting operations alone may not predict execution time.
Capacity, access latency, and bandwidth
Capacity asks how much can be stored. Access latency asks how long a particular access takes. Bandwidth asks how much data can be transferred per unit time under stated conditions. These are different measurements. A larger drive does not automatically have lower access latency; a high transfer rate does not eliminate the time needed to begin an operation.
State whether a capacity uses decimal or binary units when it matters. One kilobyte is 1000 bytes; one kibibyte is 1024 bytes. Bits and bytes also differ: 80 megabits per second is 10 megabytes per second before overhead and other limitations, because one byte has eight bits.
2. Hardware, software, and the operating system
Hardware consists of physical components. Software consists of programs and associated material used to specify behaviour. Neither a device's appearance nor its price tells you whether a particular workload will run well.
An application performs a user task. The operating system manages resources and provides services and abstractions such as processes and files. It helps applications use hardware without each application implementing every device-specific detail.
A process is an executing program together with its execution state and resources. With time sharing, the OS can give multiple processes opportunities to run on a processor. Protection mechanisms help isolate processes, although isolation is not an unconditional guarantee against all faults or attacks.
Firmware is software closely associated with a device and commonly stored in non-volatile memory. “Firmware is hardware” is inaccurate: the storage chip is hardware; the instructions stored on it are software.
The operating system as manager and boundary
Applications share finite resources. The OS schedules execution, manages memory, provides device access, and applies access-control decisions. A running program should not obtain unrestricted access to another program’s memory merely because both use the same machine.
Applications request services through defined interfaces. A library function may invoke an OS service, perform user-space work, or do both. A system call is a controlled entry into an OS service. “Every function call is a system call” is false.
For example, opening a file requires finding the file, checking access conditions, and establishing a usable handle or descriptor. Reading then requests bytes. A read can fail or return fewer bytes than requested. Robust software checks what actually happened rather than assuming the requested outcome occurred.
Source, compiler, executable, and runtime
Source code is a human-oriented program representation. A compiler translates one program representation into another; machine code is one possible target. A linker combines required code and resolves references in a conventional compiled build. A loader helps prepare an executable for running. A runtime supplies execution support required by a language or environment.
An interpreter performs a program’s behaviour through another executing program. A just-in-time compiler translates some code during execution. These are implementation strategies, not rigid categories attached forever to a programming language. What matters is the actual environment and its execution model.
Program, process, and thread
A saved program is not itself a running process. Two processes can execute the same program while maintaining different state. A process may have multiple threads that share some resources and retain separate execution state.
Concurrency is organising overlapping activities. A single core can interleave them. Parallelism is simultaneous execution of some work. Extra cores help only when the program and workload expose usable parallel work and other resource limits permit it.
3. What happens when a program runs?
A source file is not always directly executable by the processor. A compiled program may be translated into machine instructions; other programs run through an interpreter or a runtime. Some environments combine interpretation and compilation. In all cases, execution eventually depends on machine-level operations.
- The system prepares the program's execution environment. Required code and data become accessible in memory; they need not all be read from storage at once.
- At a conceptual level, the processor fetches an instruction using an instruction address.
- It decodes the instruction to determine the operation and operands.
- It performs the required action, such as computing a value, accessing memory, or changing control flow.
- It updates architectural state and proceeds to the next instruction determined by the program's control flow.
This fetch–decode–execute model explains instruction processing. It is not a timing diagram of a modern CPU: several instructions can be in different pipeline stages simultaneously.
Stored-program principle
Instructions are represented in a form that can be stored and retrieved by a machine. Changing the program changes the computation without rebuilding the underlying processor. Do not turn this principle into the claim that every computer has one physically unified instruction-and-data memory: systems may separate instruction and data paths or caches.
marks = [72, 81, 67]
total = 0
for each mark in marks:
total = total + mark
percentage = (total / 300) * 100
display percentageHere the list is data; the loop and expressions describe instructions. The total evolves from 0 to 72 to 153 to 220. The percentage is approximately 73.33%. That interpretation assumes three subjects, each out of 100. If maxima differ, calculate using their actual sum rather than hard-coding 300.
A complete execution trace using a toy machine
Use a simple machine with an accumulator register ACC, a program counter PC, and two memory values: address 200 contains 7; address 201 contains 5. Its invented instruction set contains LOAD, ADD, STORE, and HALT. This is a teaching model, not a particular commercial processor.
0: LOAD 200
1: ADD 201
2: STORE 202
3: HALT| Before instruction | Action | State after completion |
|---|---|---|
| PC = 0 | Copy memory[200] into ACC | ACC = 7; next PC = 1 |
| PC = 1 | Add memory[201] to ACC | ACC = 12; next PC = 2 |
| PC = 2 | Copy ACC into memory[202] | memory[202] = 12; next PC = 3 |
| PC = 3 | Stop this toy execution | Result remains 12 in address 202 |
LOAD copies a value; it does not erase the source location. STORE writes a value; it does not turn an address into the value itself. The PC and ACC hold different kinds of state. If the program forgot STORE, the computed answer could remain in ACC without being written to the intended result location.
Actual instruction sets include defined operand forms, registers, instruction encodings, and exception behaviour. A processor’s instruction set architecture (ISA) defines the software-visible execution contract. Its microarchitecture is an implementation of that contract. Different implementations can run compatible instructions while having different performance.
Control flow: sequence, selection, and repetition
Sequence follows successive operations. Selection chooses a path based on a condition. Repetition performs a set of operations multiple times. An instruction that changes where execution continues is often called a branch or jump, depending on the instruction set.
In the marks example, iteration reads each mark and updates a total. If the loop skips one entry, correctly implemented addition cannot repair the missing work. Tracing control flow is therefore as important as checking arithmetic.
Input/output: the CPU is not doing everything itself
Device controllers coordinate device operations. Polling checks whether an operation is ready or complete. An interrupt can notify the processor of an event through a handler. Neither mechanism is always best; checking and notification both have costs.
Some controllers use direct memory access to transfer data without making the CPU copy every unit using ordinary instructions. The CPU still sets up work and deals with results or errors. An I/O request has a lifecycle; issuing it is not the same as completing it.
Questions and answers
Easy: explain the idea. Medium: apply or compare it. Hard: analyse assumptions and trade-offs. Tags describe the question’s purpose; interview questions are original practice, not claims about a specific employer.
Main memory supplies working instructions and data to executing programs. Ordinary DRAM requires power to retain contents. Persistent storage retains files without continuous power and generally offers greater capacity with different access costs.
Opening a file typically brings required data into memory. Editing that copy does not automatically update the file. “Memory is temporary and storage is permanent” is too absolute: persistence does not protect against deletion, corruption, or device failure.
A program specifies instructions; a process is an instance of execution with state and resources. Two instances of the same application can have different memory contents, open files, and execution positions. A single application can also create multiple processes.
A process may contain several threads. Threads within that process commonly share its address space while having their own execution state, including stacks and registers. Concurrency does not imply that all threads execute simultaneously on separate cores.
Firmware is software closely associated with controlling a device and commonly stored in non-volatile memory. Its storage chip is hardware; the instructions are software. It may be updated, so “firmware can never change” is incorrect.
Device startup code and controller software are examples. Do not assume every firmware component is an operating system or every application is firmware.
Conceptually, the processor obtains an instruction, determines its operation and operands, executes it, and updates the state needed for subsequent execution. A program counter or equivalent architectural mechanism records instruction-position information.
Modern processors can overlap stages, execute some work speculatively, and have multiple execution units. The conceptual cycle describes the meaning of instruction execution; it does not prove that one instruction completes per cycle or that every instruction takes the same time.
It can help when the working set does not fit comfortably in memory and the system repeatedly moves data between memory and storage. More memory may reduce paging and allow useful caching.
It may have little effect on a task limited by CPU computation, network delay, or an inefficient algorithm when memory is already sufficient. Diagnose memory pressure and workload behaviour before treating capacity as a universal speed control.
Programs often reuse nearby or recently accessed data. A cache can serve many of these accesses at a lower cost than going to main memory. Its usefulness depends on the access pattern and whether needed data is present.
A larger cache is not automatically optimal: capacity, latency, power, and implementation costs interact. Cache hits help; cache misses still require accessing a lower level. A cache is not a replacement for persistent file storage.
No. Virtual memory provides an address-space abstraction and mechanisms for mapping addresses to physical memory. Some systems can also keep less-used memory contents in backing storage, but storage access is not equivalent to RAM access.
Address-space limits, available physical memory, configured backing storage, and OS policy still constrain execution. A page fault is not automatically an error or a disk read: the OS may be able to satisfy it in other ways, including creating a zero-filled page.
Polling checks a condition repeatedly, such as whether a device has completed a transfer. An interrupt allows an event to cause the processor to execute an appropriate handler, subject to the system’s interrupt mechanism and masking rules.
Interrupts avoid some unnecessary checking but have handling costs. Polling can be useful for frequent events or tightly controlled latency requirements. Real systems may combine both. Choose based on event rate, processing cost, responsiveness, and scheduling requirements.
A DMA-capable controller transfers data between a device and memory without requiring the CPU to copy each individual data unit using ordinary instructions. The CPU still usually prepares the operation, manages buffers, and handles completion or errors.
“DMA does not involve the CPU at all” is therefore misleading. The system must also consider access permissions, memory consistency, and buffer lifetime. DMA reduces a particular kind of transfer work; it does not eliminate every I/O cost.
Revision checkpoints
Explain the main mechanisms in your own words, reproduce the worked examples without looking, and answer the tagged questions before expanding their solutions. When an answer depends on assumptions, state them explicitly.
References and further reading
The supplied MCA syllabus defines the topic placement (Fundamentals of Computers, PDF page 9). The chapter explains its prerequisites and worked examples directly; the references support verification and optional further study. The explanations, examples, diagrams, and practice questions here are original teaching material.
- Harvard CS50, Lecture 0: introductory problem solving and binary representations.
- Operating Systems: Three Easy Pieces, Introduction to Operating Systems, by Remzi and Andrea Arpaci-Dusseau: processes, resource management, and persistence.
- Python documentation: floating-point limitations: representation error and numeric comparisons.
- Unicode Consortium: UTF encodings: bytes, code points, and encodings.
- Cornell computer architecture lecture: performance: performance metrics and Amdahl’s law.
- OSTEP: I/O devices: polling, interrupts, and DMA.
- MIT: automata, computability, and complexity: the boundaries of algorithmic computation.
Spot an error? Report it to Study Shelf with this page link.