Overview
Introduction: This chapter, Computer Systems Overview, introduces the basic building blocks of a digital computer and explains how hardware and software work together to perform computing tasks. It covers the main components — CPU, memory, input/output and storage — and introduces the concept of system software and application software. Students also learn fundamental ideas about data representation and number systems used by computers. Importance: A clear understanding of computer systems is essential for any further study in programming (Python) and practical computing. Knowing how a computer processes and stores data, what an operating system does, and how programs are translated and executed helps students write better code, debug effectively, and appreciate performance and security trade-offs. Key themes: - Hardware vs. software: components and roles - Central processing (CPU) and memory hierarchy (primary and secondary storage) - Input/output devices and their purpose - Types and functions of system software (especially operating systems) and application software - Programming languages, translators (assembler, compiler, interpreter) - Number systems and basic data…
Learning Objectives
- Define a computer system and identify its main components (hardware, software, firmware, users).
- Explain the functions of the CPU, including the Arithmetic Logic Unit (ALU) and Control Unit.
- Draw and label the von Neumann architecture and explain the role of each block.
- Differentiate between primary memory (RAM, ROM) and secondary storage (HDD, SSD, optical) with examples and uses.
- Describe types and characteristics of common input and output devices and select appropriate devices for given tasks.
- Classify software into system software, application software, and utility programs with suitable examples.
- Explain the role and key functions of an operating system (process management, memory management, file system and I/O handling).
- Perform conversions among binary, decimal and hexadecimal number systems and carry out basic binary arithmetic operations.
Topics in this chapter
20 topics · tap a topic title to jump straight to it.
Introduction to Computer Systems
Introduction to Computer Systems
Key Point: Clock cycle time = 1 / Clock rate (Hz). Example: for 2 GHz CPU, cycle time = 1 / 2×10^9 s = 0.5 ns.
What is a computer system? A computer system is an integrated set of hardware and software that accepts data (input), processes it according to instructions, stores results, and produces output. It follows the stored-program concept where instructions and data reside in memory.
Main components
- Hardware – physical devices: CPU, memory, input/output devices, secondary storage, buses.
- Software – programs and data: system software (operating system, utilities) and application software (word processors, browsers).
Central Processing Unit (CPU) – the brain of the computer. Key parts:
- Control Unit (CU) — directs operations and coordinates components.
- Arithmetic Logic Unit (ALU) — performs arithmetic and logical operations.
- Registers — small, fast storage locations used during instruction execution (e.g., program counter, instruction register, accumulator).
Memory hierarchy — different storage levels trade speed, cost and capacity:
- Cache — very fast, small; close to CPU.
- Primary memory (RAM) — volatile, read/write.
- ROM — non-volatile, stores firmware.
- Secondary storage — HDD, SSD, optical disks: large capacity, non-volatile.
Input → Processing → Output → Storage — The instruction cycle (fetch, decode, execute, store) takes data from input, processes it under CPU control, and outputs/stores results.
Types of computer systems — by size and purpose: microcomputers (PCs, laptops), workstations, minicomputers, mainframes, supercomputers, embedded systems (in appliances), mobile devices (smartphones/tablets).
System vs Application Software
- System software — manages hardware and provides common services (OS, device drivers).
- Application software — solves user-specific tasks (spreadsheets, games).
Performance basics — measured by clock speed, instruction count, CPI (cycles per instruction), throughput (instructions/sec). Improvements can come from faster clock, fewer cycles per instruction, parallelism, better memory/cache design.
Von Neumann architecture — a common model where a single memory holds both instructions and data and the CPU executes sequential instructions fetched from memory.
Data representation — computers use binary (bits 0/1). Common units: 1 byte = 8 bits, 1 KB = 1024 bytes, 1 MB = 1024 KB, etc.
Safety and reliability — fault tolerance, backups, and secure software help keep systems reliable and protect data.
Summary: A computer system integrates hardware and software to perform controlled, repeatable data processing. Understanding its components, data flow, memory hierarchy and performance factors is essential to designing and using computers effectively.
- Automated teller machine (ATM): input (card, PIN), processing (bank server verification), output (cash, receipt), storage (transaction logs).
- Smartphone: touch input, apps (application software), OS manages hardware, stores photos on flash memory.
- Supermarket billing system: barcode scanner (input), POS software (processing), receipt printer (output), daily sales stored in database (storage).
- Weather forecasting on a supercomputer: sensors gather data (input), massive parallel processing runs models (processing), forecasts published online (output).
- Embedded system in a microwave: microcontroller runs firmware (system software) to control heating cycles (processing) and display timer (output).
- \[Clock cycle time = 1 / Clock rate (Hz)\]\[Example: for 2 GHz CPU\]\[cycle time = 1 / 2×10^9 s = 0.5 ns.\]
- \[CPU cycles = Instruction count × CPI (cycles per instruction).\]
- \[CPU execution time = CPU cycles × Clock cycle time = (Instruction count × CPI) / Clock rate.\]
- \[MIPS (million instructions per second) ≈ (Instruction count / Execution time) / 10^6 = Clock rate / (CPI × 10^6) (approximation).\]
- \[FLOPS (floating-point operations per second) measures floating-point throughput (useful for scientific computing).\]
- \[Cache Effective Access Time (EAT) = h × Tc + (1 − h) × Tm\]\[where h = hit ratio\]\[Tc = cache access time\]\[Tm = memory access time.\]
Components of a Computer System
Components of a Computer System
Key Point: CPU time = (Instruction Count × CPI) / Clock Rate — where CPI is cycles per instruction, Clock Rate in cycles/second (Hz).
What is a computer system? A computer system is an integrated assembly of hardware and software that accepts data, processes it, stores results and produces output. It includes physical devices (hardware), system and application programs (software), and users.
Major hardware components
- Central Processing Unit (CPU) – The 'brain' that executes instructions. It consists of:
- Control Unit (CU) – Directs operations and sequencing (fetch–decode–execute).
- Arithmetic Logic Unit (ALU) – Performs arithmetic and logical operations.
- Registers – Very fast small storage locations (e.g., PC, IR, ACC).
- Cache – Small, fast memory (L1, L2, L3) that reduces access time to main memory.
- Main memory (Primary memory) – Volatile and directly accessible by the CPU: RAM (read/write, volatile) and ROM (read-only, non-volatile, stores firmware).
- Secondary/storage devices – Non-volatile mass storage: HDDs, SSDs, optical disks, flash drives. Used for long-term storage of data and programs.
- Input devices – Enable users to provide data: keyboard, mouse, scanner, microphone, sensors.
- Output devices – Present results: monitor, printer, speakers.
- Motherboard and buses – The circuit board that connects components. Buses carry data, addresses and control signals (data bus, address bus, control bus).
- I/O controllers and ports – Interface between CPU and peripheral devices; handle device-specific protocols and buffering.
- Network Interface – NIC/modem/wireless adapters to connect with other systems and the internet.
- Power supply – Converts and supplies required voltages to components.
Software components (brief)
- System software – Operating System (OS), device drivers, utility programs. OS manages hardware resources and provides user interface and services.
- Application software – Programs that perform user tasks (word processors, browsers, spreadsheets).
How components interact (overview)
Typical cycle: Input device -> data loaded into memory -> CPU fetches instructions/data from memory -> ALU/process -> results written back to memory or secondary storage -> Output device displays results. Communication happens over buses and is coordinated by the OS and I/O controllers.
Key distinctions
- Volatile vs non-volatile – Volatile memory (RAM) loses data when power is off; non-volatile (ROM, SSD, HDD) retains data.
- Primary vs secondary – Primary is fast and directly accessible by CPU; secondary provides large-capacity persistent storage but is slower.
- Internal vs external – Internal components are inside the system unit (CPU, motherboard); external peripherals connect to it (printer, keyboard).
Note for students: Understanding these components and their roles helps explain performance differences between devices (e.g., why SSD boots faster than HDD, or why more RAM improves multitasking).
- Desktop PC: CPU (Intel/AMD), RAM (8–16GB), SSD/HDD, monitor, keyboard and mouse — used for general computing.
- Laptop: Integrated components on a single board; battery and wireless NIC included — portable computer system.
- Smartphone: CPU (SoC), RAM, flash storage, touch screen, camera, sensors — an example of a compact computer system.
- ATM (Automated Teller Machine): Input (keypad, card reader), CPU and embedded system software, secure storage, network interface to bank servers.
- Smart TV: CPU/GPU, ROM for firmware, RAM, input (remote), output (display), network interface for streaming — special-purpose computer.
- Embedded system in a washing machine: Microcontroller (CPU), sensors, actuators and firmware — performs dedicated control tasks.
- \[CPU time = (Instruction Count × CPI) / Clock Rate — where CPI is cycles per instruction\]\[Clock Rate in cycles/second (Hz).\]
- \[Clock period (s) = 1 / Clock frequency (Hz).\]
- \[Instructions per second ≈ Clock Rate / CPI.\]
- \[Average Memory Access Time (AMAT) = Hit time + Miss rate × Miss penalty (useful for cache performance).\]
- \[Bus bandwidth (bytes/s) = (Bus width in bits × Bus frequency in Hz) / 8.\]
- \[Memory size conversions: 1 KB = 1024 bytes, 1 MB = 1024 KB = 1,048,576 bytes, 1 GB = 1024 MB.\]
Computer Hardware
Computer Hardware
Key Point: Clock period (T) = 1 / Frequency (f). Example: If f = 3 GHz, T = 1 / 3×10^9 ≈ 0.333 ns.
Definition: Computer hardware is the physical components of a computer system that you can touch — the electronic and mechanical parts that perform computation, storage, control, input and output. Hardware works together with software to perform tasks.
Main components and roles
- Central Processing Unit (CPU): The brain of the computer. It fetches, decodes and executes instructions. Internally it contains the Control Unit (CU), Arithmetic Logic Unit (ALU) and registers.
- Main Memory (Primary memory): Volatile storage used by the CPU to hold instructions and data during execution. Typical example: RAM (DRAM). ROM holds firmware and is non-volatile.
- Cache: Small, very fast memory placed close to the CPU (L1, L2, L3) to reduce average access time to frequently used data.
- Secondary Storage: Non-volatile, long-term storage for files and programs. Examples: HDD, SSD, optical drives, flash drives.
- Motherboard and Bus: The main circuit board that connects all components; buses (data, address, control) carry information between them.
- Input Devices: Devices that bring data into the computer (keyboard, mouse, scanner, sensors).
- Output Devices: Devices that present results (monitor, printer, speakers).
- GPU / Co-processors: Specialized processors for graphics or parallel tasks (can accelerate certain computations).
- Power Supply & Cooling: Provide stable power and remove heat to keep hardware within safe operating ranges.
Key properties and trade-offs
- Speed vs Capacity vs Cost: Faster memories (registers, cache) are more expensive and have smaller capacity. Secondary storage offers large capacity at lower cost but is slower.
- Volatility: RAM is volatile (loses data when power is off); ROM and secondary storage are non-volatile.
- Bottlenecks and balance: System performance depends on balanced hardware: a very fast CPU is limited by slow memory or I/O.
How components interact (basic data flow)
The CPU fetches an instruction from main memory via the memory bus. If the required data is in cache (cache hit), access is fast; if not (cache miss), data must be fetched from main memory or even secondary storage, causing delays. Input devices send data into memory or directly to CPU buffers; output devices receive processed data from memory or CPU buffers.
Practical tips for students
- Remember the hierarchy: Registers > Cache > Main memory > Secondary storage (in speed).
- Identify what is volatile vs non-volatile and what role each component plays in executing a program.
- Understand simple performance formulas (see formulas list) to reason about how hardware changes affect speed and power.
- Smartphone: SoC (system on chip) integrates CPU, GPU, memory controllers and I/O — example of compact hardware integration.
- Laptop: CPU (e.g., Intel/AMD), RAM (8–16 GB), SSD (fast secondary storage), display (output), keyboard and touchpad (input).
- Desktop gaming PC: Dedicated GPU for rendering, HDD/SSD for storage, large RAM and cooling systems for performance.
- Printer: Input (print job from PC), controller board (embedded CPU), motors (hardware) to produce paper output.
- USB flash drive: Portable non-volatile secondary storage used to transfer files between systems.
- \[Clock period (T) = 1 / Frequency (f)\]\[Example: If f = 3 GHz\]\[T = 1 / 3×10^9 ≈ 0.333 ns.\]
- \[CPU execution time = Instruction Count × CPI × Clock period = (Instruction Count × CPI) / Clock frequency. (CPI = cycles per instruction)\]
- \[Amdahl's Law (speedup when improving part of a system): Speedup_total = 1 / ((1 - f) + f / S)\]\[where f is fraction accelerated and S is speedup of that fraction.\]
- \[Cache Effective Access Time (EAT) = (Hit rate × Hit time) + (Miss rate × Miss penalty).\]
- \[Dynamic power (approx.) P ∝ C × V^2 × f\]\[where C = capacitance switched\]\[V = supply voltage\]\[f = switching frequency.\]
- \[Bandwidth (bytes/s) = (Bus width in bytes) × (Bus frequency).\]
Types and Classifications of Computers
Types and Classifications of Computers
Key Point: CPU Time = Instruction Count × CPI × Clock Cycle Time
Introduction
A computer is an electronic device that accepts data, processes it under the control of sets of instructions called programs, and produces output. Computers can be classified in several ways depending on size, purpose, data handled and computing power. Understanding these classifications helps choose the right machine for a task.
1. Classification by Size / Power
- Microcomputer (Personal Computer): Small, single-user machines such as desktops, laptops, tablets and smartphones. Fast enough for everyday tasks (word processing, web browsing, multimedia).
- Minicomputer (Midrange Computer): Costlier and more powerful than microcomputers; used by small businesses or departments. Today minicomputers are often considered small servers.
- Mainframe Computer: Large, powerful systems supporting hundreds or thousands of simultaneous users; high transaction throughput and reliability. Used in banks, large corporations, airlines.
- Supercomputer: Extremely fast machines optimized for scientific simulations, climate modelling, cryptography and large-scale computations. Measured in FLOPS (floating-point operations per second).
2. Classification by Purpose
- General-purpose computers: Designed to perform a wide variety of tasks by running different programs (e.g., PCs, servers).
- Special-purpose computers: Built to perform a specific task or set of tasks (e.g., embedded controllers in washing machines, traffic-light controllers, digital cameras).
3. Classification by Data Handled
- Analog computers: Work with continuously varying data (used historically for simulations and control systems).
- Digital computers: Work with discrete values (0 and 1). Most modern computers are digital.
- Hybrid computers: Combine analog and digital features to benefit from both (rare; used in specialized scientific applications).
4. Other Common Types / Terms
- Workstation: A powerful single-user machine for technical or scientific applications (CAD, graphics, software development).
- Server: Provides services (files, web, database) to other computers (clients) over a network. Servers range from small to large (rack, blade).
- Cluster / Grid / Cloud: Multiple machines working together to provide greater compute power or availability. Used in data centres and high-performance computing.
Key characteristics to compare: processing speed (clock rate, cores), memory size, storage capacity, number of simultaneous users supported, reliability, cost and physical size.
Summary
Classification helps match a computer's capabilities to needs: personal tasks use microcomputers; business departments use servers/minicomputers; mission-critical transaction processing uses mainframes; large scientific computations use supercomputers; embedded/special-purpose devices control appliances and equipment.
- Microcomputer / Personal Computer: Desktop PC used at home for browsing, document editing and media.
- Laptop: Student’s laptop for programming and assignments.
- Smartphone / Tablet: Mobile devices used for communication, apps and internet.
- Workstation: CAD workstation for mechanical design and 3D modelling.
- Server: A web server hosting websites and databases in a data center.
- Minicomputer / Small Business Server: A departmental file and print server in a school.
- \[CPU Time = Instruction Count × CPI × Clock Cycle Time\]
- \[CPU Time = (Instruction Count × CPI) / Clock Rate\]
- \[FLOPS (approx) = Number of floating-point operations / Time (used to measure supercomputer performance)\]
- \[Amdahl's Law (speedup by parallelization): Speedup = 1 / ((1 - p) + p / s) where p = fraction of task parallelizable\]\[s = speedup of parallel portion\]
- \[Storage size conversions: 1 KB = 1024 B, 1 MB = 1024 KB, 1 GB = 1024 MB\]\[etc.\]
- \[MIPS (approx) = Instruction Count / (Execution time × 10^6) (Note: MIPS is not always a reliable performance metric)\]
Generations of Computers
Generations of Computers
Key Point: Moore's Law (informal): transistor_count ≈ initial_count × 2^(t / T_doubling). Typical historical T_doubling ≈ 18–24 months. (Shows exponential growth of transistor density.)
Overview: Computers are classified into generations based on the dominant technology used for their internal components (switching devices, memory, processors) and the resulting changes in size, speed, cost, reliability and programming capabilities. Each generation introduced new hardware and software innovations that shaped computing.
First Generation (1940s–1956) — Vacuum Tubes
- Technology: Vacuum tubes for logic and switching.
- Characteristics: Very large size, high power consumption, low reliability (frequent failures), programming in machine language.
- Typical uses: Scientific calculations and early business data processing.
- Examples: ENIAC, UNIVAC I.
Second Generation (1956–1965) — Transistors
- Technology: Discrete transistors replaced vacuum tubes.
- Characteristics: Smaller, faster, more reliable, lower power than vacuum tubes; introduction of assembly language and early high-level languages (FORTRAN, COBOL).
- Typical uses: Business, engineering, batch processing.
- Examples: IBM 1401, PDP-8.
Third Generation (1965–1971) — Integrated Circuits (ICs)
- Technology: ICs (multiple transistors on a single chip).
- Characteristics: Further reduction in size and cost, improved performance and reliability; time-sharing and multiprogramming operating systems appear.
- Typical uses: Real-time systems, commercial and scientific computing.
- Examples: IBM System/360, DEC PDP-11.
Fourth Generation (1971–present) — Microprocessors / VLSI
- Technology: Microprocessors (CPU on a single chip), Very Large Scale Integration (VLSI).
- Characteristics: Personal computers, dramatic fall in cost, widespread use, GUIs, networks and client-server computing.
- Typical uses: Personal computing, embedded systems, networking, mobile devices.
- Examples: Intel 8086 and later x86 family, Apple II, IBM PC, modern laptops and smartphones.
Fifth Generation (1990s–present & beyond) — AI, Parallelism, ULSI
- Technology: Ultra-Large-Scale Integration (ULSI), parallel processing, specialized AI hardware (GPUs, TPUs), quantum prototypes and neuromorphic chips under research.
- Characteristics: Focus on natural language processing, expert systems, machine learning, huge parallelism, energy-efficient architectures.
- Typical uses: AI applications, big data analytics, cloud computing, autonomous systems.
- Examples: Modern supercomputers, cloud servers, smartphones running AI models, Google TPU, IBM Watson.
Key trends across generations:
- Size: decreases dramatically from room-sized to pocket-sized.
- Speed & performance: increases exponentially (more instructions per second, higher clock rates, more parallelism).
- Cost per computation: falls sharply.
- Reliability: improves (mean time between failures increases).
- Programming abstraction: moves from machine code to high-level languages and intelligent systems.
Practical note for students: When asked about generations, mention the core hardware technology, the main improvements (size, speed, power), typical programming model, and one or two examples for each generation.
- First generation: ENIAC used for ballistic and scientific calculations.
- Second generation: IBM 1401 used for business data processing and payroll.
- Third generation: IBM System/360 used in large enterprises, supporting different models with compatible software.
- Fourth generation: IBM PC and modern laptops—personal computing, office software, web browsing and gaming.
- Fifth generation: Smartphones using AI features (voice assistants), cloud servers running large ML models, GPUs/TPUs accelerating deep learning.
- \[Moore's Law (informal): transistor_count ≈ initial_count × 2^(t / T_doubling)\]\[Typical historical T_doubling ≈ 18–24 months. (Shows exponential growth of transistor density.)\]
- \[CPU Performance (basic relation): Performance ∝ Clock_Frequency × Instructions_Per_Clock (IPC). (Higher clock or IPC increases throughput.)\]
- \[Amdahl's Law (parallel speedup limit): Speedup = 1 / ((1 - p) + p / s)\]\[where p = fraction of program that can be parallelized\]\[s = speedup of the parallel portion. (Limits benefit of parallelism.)\]
- \[Dynamic Power in CMOS circuits: P ∝ C × V^2 × f\]\[where C = capacitance switched\]\[V = supply voltage\]\[f = switching frequency. (Explains why lowering voltage and frequency reduces power.)\]
Von Neumann Architecture
Von Neumann Architecture
Key Point: CPU execution time = Instruction count × CPI × Clock cycle time (where CPI = cycles per instruction).
Definition: The Von Neumann Architecture (also called the stored-program concept) is a computer architecture model in which program instructions and data share the same memory space. It was proposed by John von Neumann and colleagues in the 1940s and is the basis for most general-purpose computers.
Main components:
- Memory: Stores both program instructions and data in a single addressable space.
- Central Processing Unit (CPU): Consists of the Arithmetic Logic Unit (ALU) for computations and the Control Unit (CU) to manage instruction sequencing and control signals.
- Input/Output (I/O): Devices and interfaces used to receive input and deliver output.
- Buses: Data bus (transfers data), address bus (specifies memory locations) and control bus (carries control signals).
Working principle — Fetch-Decode-Execute cycle:
- Fetch: CU places the address of the next instruction on the address bus and retrieves the instruction from memory into the instruction register.
- Decode: The CU decodes the instruction to determine required operations and operands.
- Execute: ALU performs the operation (arithmetic/logic), possibly reading/writing data in memory. Then the CU updates the program counter and repeats the cycle.
Key characteristics:
- Programs are stored as binary data in memory; the CPU treats instructions and data similarly (fetching from the same memory).
- Simple and flexible design; easy to implement general-purpose computing.
- Has a limitation known as the Von Neumann bottleneck: the single shared memory and single bus limit the rate at which instructions and data can be transferred between memory and CPU, creating a throughput/latency bottleneck.
Advantages:
- Uniform memory simplifies programming and compiler design.
- Hardware is simpler than architectures that separate instruction and data memory.
- Suitable for general-purpose computing.
Disadvantages:
- Memory bandwidth becomes a limiting factor (Von Neumann bottleneck).
- Security risks if data is executed as code (requires protections such as NX bit in modern systems).
Historical note: The Von Neumann model laid the foundation for modern computers. Many modern systems extend the model (cache memory, pipelines, separate instruction/data caches) to mitigate its limitations while keeping the stored-program idea.
- A typical desktop or laptop computer where programs (applications) and data are stored in the same RAM and loaded to the CPU for execution.
- General-purpose servers executing stored software: the server's programs and data reside in main memory and are fetched by the CPU following the fetch-decode-execute cycle.
- Many general-purpose embedded systems and microprocessors used in appliances and industrial controllers follow the stored-program concept (instructions and data in a single memory space).
- Simple teaching simulators and software emulators of CPUs that implement the Von Neumann fetch-decode-execute loop to run programs.
- \[CPU execution time = Instruction count × CPI × Clock cycle time (where CPI = cycles per instruction).\]
- \[Clock period (T) = 1 / Clock frequency (f)\]\[So CPU time per cycle = T seconds.\]
- \[Effective memory access time (EMAT) = (Hit rate × Hit time) + (Miss rate × Miss penalty) — used when caches are present to model the Von Neumann bottleneck mitigation.\]
- \[Throughput ≈ 1 / (average time per instruction) — improvements (like pipelining) aim to reduce average time per instruction.\]
Central Processing Unit (CPU)
Central Processing Unit (CPU)
Key Point: CPU Time = Instruction Count (IC) × CPI × Clock Cycle Time
What is a CPU? The Central Processing Unit (CPU) is the primary component of a computer that performs computation and controls the operation of the system. It fetches instructions from memory, decodes them, executes operations (arithmetic, logical, control), and stores results. The CPU is often called the "brain" of the computer.
Main components of the CPU
- Control Unit (CU): Directs and coordinates the activities of the CPU and other hardware by interpreting instructions and generating control signals.
- Arithmetic Logic Unit (ALU): Performs arithmetic (add, subtract) and logical (AND, OR, NOT, comparisons) operations.
- Registers: Small, very fast storage locations inside the CPU used to hold operands, intermediate results, the instruction register (IR), program counter (PC), accumulator and special-purpose registers (e.g., status/flags).
- Cache: Small fast memory close to the CPU (L1, L2, sometimes L3) that reduces average memory access time by storing frequently used data and instructions.
- Buses: Data, address and control buses carry information between CPU, memory and I/O devices.
Instruction cycle (Fetch → Decode → Execute)
- Fetch: CPU reads an instruction from memory address in the Program Counter (PC) into the Instruction Register (IR). PC is incremented.
- Decode: Control Unit decodes the instruction to determine the operation and required operands.
- Execute: ALU or other hardware units perform the operation; results written back to registers or memory. Conditional instructions can change the PC.
Performance factors
- Clock frequency (f): Higher frequency gives smaller clock period and can increase instructions per second if other factors remain the same.
- Instruction Count (IC): Total number of instructions executed for a program—depends on program and compiler.
- CPI (cycles per instruction): Average number of clock cycles each instruction takes on the CPU. Pipelining and parallelism reduce effective CPI.
- Microarchitecture: Single-core vs multi-core, pipelined stages, superscalar execution and branch prediction affect throughput and latency.
Modern CPU features
- Pipelining: Overlaps fetch/decode/execute stages for different instructions to increase instruction throughput.
- Superscalar: Multiple execution units allow executing more than one instruction per cycle.
- Multiple cores: Multiple CPU cores on a chip allow parallel execution of separate threads/processes.
- Branch prediction and out-of-order execution: Improve flow through the pipeline and reduce stalls.
Interaction with the operating system
The OS schedules processes/threads on CPU cores, handles context switching (saving/restoring registers), and provides abstraction (process isolation, virtual memory) so applications do not directly control hardware scheduling.
Safety and limitations
CPU performance can be limited by memory latency ("memory wall"), I/O bottlenecks, heat dissipation and power consumption. Efficient software and caching help mitigate these limits.
- Smartphone: The phone’s CPU (SoC) runs apps, handles the camera pipeline, UI and communications—multiple cores balance background tasks and interactive apps.
- Laptop/desktop: Intel/AMD CPU executes the OS and applications; high-frequency cores benefit single-threaded tasks (e.g., gaming), while many cores help parallel workloads (e.g., video rendering).
- Traffic signal controller: A microcontroller (simple CPU) reads sensors and executes control logic to change lights on a schedule or in response to traffic.
- Washing machine: Embedded CPU runs the user interface, monitors sensors, and controls motor cycles according to programmed wash routines.
- ATM: CPU manages user interaction, encrypts/decrypts transactions, communicates with bank servers and controls cash dispenser hardware.
- \[CPU Time = Instruction Count (IC) × CPI × Clock Cycle Time\]
- \[CPU Time = (Instruction Count × CPI) / Clock Rate (where Clock Rate = 1 / Clock Cycle Time)\]
- \[MIPS = (Instruction Count / Execution Time) / 10^6\]
- \[Speedup = Execution time_old / Execution time_new\]
- \[Amdahl's Law: Speedup_overall = 1 / ((1 - P) + P / S) where P = fraction improved\]\[S = speedup of improved part\]
- \[Clock Period (T) = 1 / Frequency (f)\]
Memory Organization
Memory Organization
Key Point: Maximum addressable units = 2^n (where n = number of address lines). Example: n=16 => 2^16 = 65536 addressable bytes.
What is Memory Organization?
Memory organization describes how different types of storage (registers, cache, main memory, secondary storage) are arranged, addressed and accessed by the CPU to hold instructions and data. It explains the hierarchy, addressing schemes, access times and strategies that make a computer both fast and cost-effective.
Memory Hierarchy (concept)
- Registers: smallest, fastest, inside CPU — hold operands and intermediate results.
- Cache: very fast, small; stores recently/frequently used data (levels L1, L2, L3).
- Main memory (RAM): larger, slower than cache; holds active programs and data.
- Secondary storage (HDD/SSD): non-volatile, very large, much slower.
- Archival/remote storage: off-line/remote backups (magnetic tape, cloud).
Key properties compared
- Access time / latency: decreases up the hierarchy (registers fastest).
- Capacity: increases down the hierarchy (secondary storage largest).
- Cost per bit: increases up the hierarchy (registers most expensive).
- Volatility: registers/cache/RAM usually volatile; SSD/HDD non-volatile.
Locality of reference
Programs tend to access a small portion of their address space at any time. Two kinds:
- Temporal locality — recently used items likely used again soon.
- Spatial locality — nearby addresses likely used soon (sequential access).
Addressing & capacity
Memory is organized as addressable units (usually bytes). If a system has n address lines, it can address 2^n units. There are two common schemes:
- Byte-addressable: each address refers to a byte.
- Word-addressable: each address refers to a word (multiple bytes).
Cache basics & mapping
Cache stores blocks (cache lines) from main memory. Main mapping techniques:
- Direct mapping — each main-memory block maps to exactly one cache line (simple, fast).
- Fully associative — a block can be placed in any cache line (flexible, slower search).
- Set-associative — compromises between the two (cache divided into sets).
Effective Access Time (EAT)
EAT models average memory access considering cache hits and misses (formula below).
Virtual memory & paging
When physical RAM is insufficient, operating systems use secondary storage as an extension (virtual memory). Memory is divided into fixed-size pages; pages are swapped between RAM and disk. Page tables map virtual addresses to physical frames. Page faults occur when a referenced page is not in RAM, causing a disk access (very slow).
SRAM vs DRAM
SRAM (Static RAM): uses flip-flops, faster, used for cache; DRAM (Dynamic RAM): stores bits as capacitors, slower, cheaper, used for main memory — needs periodic refresh.
Memory size units (binary)
1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB (used in most computer architecture contexts).
Why organization matters
Good memory organization (hierarchy, caching, addressing) minimizes average access time and cost while maximizing usable capacity. It balances speed and price to give efficient system performance.
- Desk analogy: Registers = items on your desk (immediate reach), Cache = items in the top drawer (quick reach), Main memory = filing cabinet in the room (slower), Secondary storage = off-site warehouse (slowest).
- Wallet analogy: Cash in hand (registers), Cash in wallet (cache), Bank account (main memory), Safe deposit box (secondary storage).
- Library: Recently read books on a table (cache), books on nearby shelves (RAM), books in archive room or other library branch (disk/storage).
- Video streaming: Player buffers a few seconds (cache) to avoid interruptions while the rest is downloaded (remote storage).
- Virtual memory: Having limited desk space, you keep only current chapter, while older chapters are kept in a box and fetched when needed (page swapping).
- \[Maximum addressable units = 2^n (where n = number of address lines)\]\[Example: n=16 => 2^16 = 65536 addressable bytes.\]
- \[If word size = w bytes and address lines = n (word-addressable): total memory (bytes) = 2^n * w.\]
- \[Number of address lines required for memory size M (bytes): n = log2(M)\]\[Example: 1 MB = 2^20 bytes => n = 20 address lines for byte-addressable 1 MB.\]
- \[Effective Access Time (EAT) with one-level cache: EAT = (hit_ratio * t_cache) + ((1 - hit_ratio) * (t_cache + t_memory))\]\[where t_cache = cache access time\]\[t_memory = main memory access time.\]
- \[Relation between hit_ratio (h) and miss_ratio (m): m = 1 - h.\]
Primary Memory Types
Primary Memory Types
Key Point: Memory capacity (bits) = number_of_locations × word_size (bits). Example: 2^16 locations × 8-bit word = 524,288 bits = 64 KB.
Primary memory (also called main memory) is the storage that the CPU can directly access. It holds the programs and data currently in use. Primary memory is faster but more expensive per byte than secondary storage and is usually volatile (loses data when power is off) except some ROM types.
Main components / types:
- Registers: Very small, very fast storage inside the CPU used to hold operands, intermediate results and addresses. Size: a few bytes to a few dozen bytes. Access time: one CPU cycle.
- Cache memory: Small, very fast memory placed between CPU and main memory to reduce average access time. Organized in levels: L1 (fastest, smallest), L2, L3 (slower, larger). Typically implemented with SRAM.
- Main memory (RAM): Read-Write memory used to load the OS, programs and data. Two common physical types:
- SRAM (Static RAM): fast, expensive, retains data as long as power is on, used for cache.
- DRAM (Dynamic RAM): slower than SRAM, needs periodic refresh, cheaper per bit, used for main system RAM (e.g., DDR4, DDR5).
- ROM (Read-Only Memory): Non-volatile memory used to store firmware (e.g., BIOS/UEFI). Varieties:
- MROM (Masked ROM): programmed at manufacture (not changeable).
- PROM (Programmable ROM): one-time programmable.
- EPROM (Erasable PROM): erased by UV light and reprogrammed.
- EEPROM / Flash: electrically erasable and programmable (used for firmware and small persistent storage).
Key characteristics to compare:
- Volatility: RAM is volatile; ROM, EEPROM are non-volatile.
- Speed: Registers > Cache (SRAM) > Main RAM (DRAM) > Secondary storage.
- Capacity: Registers < Cache < Main RAM << Secondary storage.
- Cost per byte: Registers > SRAM > DRAM > secondary storage (cheaper).
How they work together (memory hierarchy): CPU first checks registers, then cache, then main memory. If data is not in cache (a cache miss), it is fetched from main memory and possibly stored in cache for future accesses. This hierarchical design gives a balance of speed and capacity.
Important notes for CBSE Class 11: Understand definitions and differences between RAM and ROM, examples of each, reasons for having multiple types (speed vs cost vs volatility), and simple formulas linking addresses and capacity (see formulas section).
- CPU registers: The accumulator or program counter inside the processor used during instruction execution.
- Cache: L1 cache inside the CPU stores recently used instructions/data so the CPU can access them in nanoseconds.
- Main RAM (DRAM): The 8 GB or 16 GB DDR4 memory module in a laptop where the operating system and applications run.
- ROM / EEPROM: BIOS/UEFI firmware stored in non-volatile EEPROM/Flash on the motherboard.
- PROM/EPROM example: Older game cartridges or firmware chips that were manufactured/programmed once (PROM) or erased by UV (EPROM).
- \[Memory capacity (bits) = number_of_locations × word_size (bits)\]\[Example: 2^16 locations × 8-bit word = 524,288 bits = 64 KB.\]
- \[Number of address lines n = log2(number_of_locations)\]\[Example: 64 KB (65536 locations) needs n = log2(65536) = 16 address lines (if word size = 1 byte).\]
- \[Throughput (words per second) = 1 / access_time (seconds)\]\[If access time = 50 ns\]\[throughput = 20 million accesses/sec.\]
- \[Effective Access Time (EAT) with cache: EAT = h × Tc + (1 − h) × Tm\]\[where h = cache hit ratio\]\[Tc = cache access time\]\[Tm = main memory access time.\]
- \[Byte conversions commonly used: 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB.\]
Secondary Storage
Secondary Storage
Key Point: Capacity (disk geometry) = cylinders × heads (tracks per cylinder) × sectors per track × bytes per sector
Definition: Secondary storage (also called auxiliary or external storage) is non-volatile memory used to store data and programs permanently or for long-term use. Unlike primary storage (RAM), secondary storage retains information when power is off.
Role & difference from primary storage: Primary storage (RAM) is fast and volatile, used for active processing. Secondary storage is slower but provides high capacity and persistence for files, applications, backups and archival.
Key characteristics: non-volatile (data persists), larger capacity, lower cost per byte, slower access times, various form factors and technologies, used for storage hierarchy below RAM and cache.
Types & examples of technologies: Magnetic (HDDs, magnetic tape) – use magnetic surfaces and moving heads; Optical (CD, DVD, Blu-ray) – use lasers to read pits/lands; Flash-based (SSDs, USB drives, SD cards) – use NAND flash memory (no moving parts); Cloud/object storage – remote secondary storage accessed over networks (conceptually similar role).
Access methods: Sequential access (e.g., magnetic tape) reads data in order; Direct/random access (e.g., HDD, SSD) can read/write blocks independently. Files are stored in fixed-size blocks or sectors; file systems map files to these blocks.
Performance metrics: Capacity (bytes), latency/access time (how long to start reading), throughput/transfer rate (bytes/sec), IOPS (input/output operations per second), mean time between failures (MTBF) and durability. For magnetic disks, access time typically = seek time + rotational latency + transfer time.
Organization: Disks are organized into cylinders, tracks, sectors (or logical blocks). File systems group sectors into clusters. Modern SSDs present logical block addresses that map to physical flash locations via a controller and wear-leveling.
Cost & suitability: HDDs: high capacity, low cost/GB, good for bulk storage and backups. SSDs: faster, more expensive/GB, good for OS, applications, databases. Optical/tape: archival/long-term offline storage. Flash drives/SD cards: portable secondary storage for devices.
Use cases: persistent storage of OS, applications, user files, databases, backups and archival, media libraries, virtualization storage, and off-site/cloud backups.
- Hard Disk Drive (HDD) — magnetic platters used for desktops and servers (high capacity, moderate speed).
- Solid State Drive (SSD) — NAND flash, used for faster boot and application loads (low latency, no moving parts).
- USB flash drive — portable flash-based storage for file transfer and temporary backup.
- SD / microSD card — removable flash storage for cameras, phones and IoT devices.
- Optical discs (CD/DVD/Blu-ray) — removable read/write or read-only media for distribution and archival.
- Magnetic tape — sequential access medium used for long-term backups and cold storage in data centers.
- \[Capacity (disk geometry) = cylinders × heads (tracks per cylinder) × sectors per track × bytes per sector\]
- \[Average access time = average seek time + average rotational latency + transfer time\]
- \[Average rotational latency = 0.5 × (60 / RPM) seconds (since average wait is half a revolution)\]
- \[Transfer time = data size (bytes) / transfer rate (bytes/second)\]
- \[IOPS (approx) = 1 / average I/O latency (seconds) — useful for small random I/O workloads\]
- \[Unit conversions (binary): 1 KB = 1024 bytes, 1 MB = 1024 KB = 1,048,576 bytes, 1 GB = 1024 MB\]
Cache and Virtual Memory
Cache and Virtual Memory
Key Point: Cache effective access time: EAT_cache = t_c + (1 − h) × t_m, where t_c = cache access time, t_m = memory access time, h = hit rate.
Overview
Cache and virtual memory are techniques OSes and hardware use to give the CPU fast access to data and to let programs use more memory than physically available.
Cache Memory
- Definition: A small, very fast memory placed between the CPU and main memory (RAM) that stores copies of frequently used data to reduce average access time.
- Why it is needed: CPU speed >> RAM speed. Cache stores recently or frequently used instructions/data exploiting locality so the CPU spends less time waiting for memory.
- Levels: L1 (smallest, fastest, on-core), L2 (larger, slower), L3 (shared, larger, slower). Multilevel caches balance size and speed.
- Key concepts:
- Cache hit: requested data found in cache.
- Cache miss: data not present, fetched from lower level (RAM) and placed in cache.
- Hit ratio (h) and miss ratio (1 − h).
- Replacement policies: LRU (Least Recently Used), FIFO, Random.
Cache performance — effective access time (EAT)
If t_c = cache access time, t_m = memory access time and h = hit rate, a common formula is:
EAT = t_c + (1 − h) · t_m
(This assumes a miss requires a memory access in addition to the initial cache access. Equivalent: EAT = h · t_c + (1 − h) · (t_c + t_m)).
Virtual Memory
- Definition: A memory management technique that gives processes the illusion of a large contiguous memory (virtual address space) while using physical RAM and disk (swap) behind the scenes.
- Why it is needed: Allows programs larger than physical RAM to run, provides process isolation, and simplifies memory management.
- Paging: Virtual memory is usually implemented with fixed-size pages. A virtual address is split into a page number and an offset. The OS maps page numbers to physical frames using a page table.
- Page fault: If the page is not in RAM, the OS loads it from disk (swap) causing a page fault — a very expensive operation.
- Replacement policies: LRU, FIFO, Optimal (theoretical), Clock algorithm.
Address translation example (concept): For a 16-bit virtual address with 1 KB pages, offset size = 10 bits (1 KB = 2^10), page number = 6 bits (16 − 10 = 6). The page table maps the 6-bit page number to a frame number; the offset is unchanged.
Virtual memory performance — EAT with page faults
If p = page-fault rate (probability of a memory reference causing a page fault), t_mem = memory access time, t_pf = page-fault service time (disk I/O + OS overhead), then:
EAT = (1 − p) · t_mem + p · t_pf
Because t_pf is orders of magnitude larger than t_mem, even a tiny p greatly increases EAT.
Locality principle
Cache and virtual memory both exploit locality: temporal locality (recently used items likely reused soon) and spatial locality (nearby addresses likely accessed soon).
Summary
- Cache: hardware layer for speed; small and fast; reduces average access time by storing frequently used data.
- Virtual memory: OS technique using disk + RAM to give large address spaces; uses paging and page tables; costly page faults must be minimized.
- CPU cache example: L1 cache access time 2 ns, RAM access time 50 ns, hit rate 90% → EAT = 2 + (1 − 0.9) × 50 = 7 ns. This shows cache dramatically reduces average access time.
- Virtual memory example: If memory access takes 200 ns but a page fault costs 10 ms (10,000,000 ns), then with a page-fault rate p = 10^−6 the EAT ≈ (1 − p) × 200 + p × 10,000,000 ≈ 210 ns. A higher p (e.g., 10^−3) would make EAT ≈ 10,200 ns — huge slowdown.
- Address splitting example: 32 KB virtual address space (15 bits) with page size 256 bytes (8 bits) → offset = 8 bits, page number = 7 bits. A virtual address like 0x1A3 maps to page number 0x03 and offset 0xA3.
- \[Cache effective access time: EAT_cache = t_c + (1 − h) × t_m\]\[where t_c = cache access time\]\[t_m = memory access time\]\[h = hit rate.\]
- \[Alternate form: EAT_cache = h × t_c + (1 − h) × (t_c + t_m).\]
- \[Virtual memory EAT with page faults: EAT_vm = (1 − p) × t_mem + p × t_pf\]\[where p = page-fault rate\]\[t_mem = memory access time\]\[t_pf = page-fault service time (including disk I/O).\]
- \[Address division: Virtual address (n bits) with page size 2^k bytes → offset = k bits\]\[page number = n − k bits.\]
Instruction Cycle / Machine Cycle
Instruction Cycle / Machine Cycle
Key Point: Clock cycle time = 1 / Clock rate
Definition: The instruction cycle (or machine cycle) is the sequence of steps the CPU performs to fetch an instruction from memory, decode it, execute it and store the result. It repeats for every instruction in a program and is often called the fetch–decode–execute cycle.
High-level steps:
- Fetch: CPU fetches the instruction stored at the memory address held in the Program Counter (PC). The address goes into Memory Address Register (MAR). The memory returns the data into Memory Data Register (MDR). Instruction is moved to the Instruction Register (IR). PC is incremented to point to the next instruction.
- Decode: Control Unit (CU) decodes the bits in the IR to determine the operation and the operands (registers, immediate values, or memory addresses). The CU sets up control signals for execution.
- Execute: The Arithmetic Logic Unit (ALU) or other functional unit performs the operation (arithmetic, logic, memory read/write, I/O). If the instruction needs data from memory, an additional memory access occurs.
- Store / Write-back: The result is written back to a register or memory location (e.g., into the Accumulator or MDR). Then the cycle repeats for the next instruction.
Key CPU registers involved: PC (Program Counter), MAR (Memory Address Register), MDR (Memory Data Register), IR (Instruction Register), Accumulator / General-purpose registers, ALU, Control Unit.
Machine cycle variants (brief): Most systems break the activity into machine cycles like Instruction Fetch, Indirect Addressing (if needed), Execute, and Interrupt Cycle (if servicing interrupts). Each machine cycle itself consists of one or more clock cycles (T-states).
Timing view: A machine cycle spans several clock pulses. A single instruction may require several machine cycles (for example: fetch + memory access + execute). For performance analysis we use clock rate and counts of cycles.
Why it matters: Understanding these steps explains how instructions translate into hardware actions, why some instructions take longer (more memory accesses or complex operations), and why pipelining increases throughput by overlapping these stages.
Simple flowchart (conceptual): Fetch → Decode → Execute → Store/Write-back → Repeat.
- Real-life (chef/recipe): Fetch = read the recipe step, Decode = understand what ingredient/technique is required, Execute = perform the cooking step, Store = place the prepared ingredient/result on the plate for next steps.
- Fetch of a data addition: PC points to 'ADD R1, R2' in memory → CPU fetches instruction to IR → CU decodes meaning 'add contents of R1 and R2' → ALU adds values → result stored in R1 (write-back).
- Numerical timing example: Program has 1,000,000 instructions, average CPI = 2, clock rate = 2 GHz. CPU time = IC × CPI × clock cycle time = 1,000,000 × 2 × (1/2×10^9) = 0.001 s (1 ms).
- \[Clock cycle time = 1 / Clock rate\]
- \[CPU time = Instruction count × CPI × Clock cycle time (where CPI = cycles per instruction)\]
- \[CPI = Σ (fraction of instructions of type i × cycles per instruction of type i)\]
- \[Execution time of one instruction ≈ (number of machine cycles for that instruction) × (clock cycles per machine cycle) × (clock cycle time)\]
Buses and Data Transfer
Buses and Data Transfer
Key Point: Maximum addressable locations (if address bus has n lines): Addressable locations = 2^n (e.g., n=32 → 2^32 locations).
What is a bus?
A bus is a set of electrical lines (wires) that carry data, addresses and control signals between computer components (CPU, memory, I/O). It is a shared communication path that enables components to read from and write to each other.
Types of bus lines
- Data bus – carries the actual data. Its width (number of lines) is given in bits (e.g., 8, 16, 32, 64 bits). Wider buses move more data per transfer.
- Address bus – carries addresses that select memory locations or I/O devices. The number of address lines (n) determines the maximum directly addressable locations: 2^n.
- Control bus – carries control and timing signals such as Read, Write, Interrupt, Clock, Memory/IO select, etc.
Key properties
- Bus width: number of parallel lines for data or address (affects how much data or which addresses can be handled).
- Bus frequency/clock: for synchronous buses, transfers occur on clock edges. Higher clock → higher potential throughput.
- Direction: data buses can be unidirectional or bidirectional.
- Parallel vs Serial: Parallel buses transfer many bits at once (fast over short distances). Serial buses send bits sequentially over fewer wires (better for long distances and high frequencies, e.g., USB, PCIe).
- Synchronous vs Asynchronous: Synchronous buses use a shared clock; asynchronous buses use handshaking signals to manage timing.
How a bus transfer works (basic read cycle)
- CPU places address on the address bus and sets control signals (Memory Read).
- Memory decodes the address and places data on the data bus.
- CPU reads data and deasserts control signals — one bus cycle completed.
Bus contention and arbitration
Because the bus is shared, multiple devices cannot drive it at the same time. Bus arbitration decides which device gets control. Common methods: centralized arbiter (single controller grants access), distributed arbitration (devices compete by priority lines), and daisy-chain.
Special concepts
- Tri-state drivers: Allow devices to disconnect from the bus (high-impedance) so others can drive the lines.
- Multiplexed buses: Address and data lines may be shared at different times to reduce pin count (address first, data later).
Practical notes
Modern systems use layered buses: system/motherboard bus (memory/CPU), peripheral buses (PCIe, USB), and serial links for longer distances. Performance depends on bus width, clock, protocol overhead, and arbitration latency.
- Memory access with a 32-bit data bus and 32-bit address bus: CPU places address on the 32 address lines (can address 2^32 bytes = 4 GB if byte-addressable), data moves on 32 data lines (4 bytes per transfer).
- Calculation example: 32-bit bus at 100 MHz → raw bandwidth = 32 bits × 100×10^6 Hz = 3.2×10^9 bits/s = 400 MB/s (3.2 Gbps).
- USB (serial) vs old parallel printer cable: USB serializes data over fewer wires and works reliably over longer cables; parallel cable sent many bits in parallel but was bulky and prone to signal skew.
- PCI Express (PCIe): a high-speed serial bus using lanes (x1, x4, x16). A lane serializes bits but multiple lanes aggregate bandwidth (e.g., x16 for a graphics card).
- Analogy: Bus width = number of lanes on a highway; clock frequency = cars per minute; control signals = traffic lights deciding which car goes next.
- \[Maximum addressable locations (if address bus has n lines): Addressable locations = 2^n (e.g.\]\[n=32 → 2^32 locations).\]
- \[Raw bandwidth (bits per second) = bus_width_in_bits × clock_frequency (Hz).\]
- \[Bandwidth (bytes per second) = (bus_width_in_bits × clock_frequency) / 8.\]
- \[Transfer time (seconds) = data_size_in_bytes / bandwidth_in_bytes_per_second.\]
- \[Effective throughput with cycles per transfer: Throughput = (bus_width_in_bits × frequency) / cycles_per_transfer (bits/s).\]
Software Overview
Software Overview
Key Point: Defect density = Number of defects / Size of software (KLOC) e.g., defects per KLOC
What is Software? Software is a set of instructions and data that tells computer hardware what to do. Unlike hardware (the physical parts), software is intangible and provides functionality — from basic system control to user-facing applications.
Major classifications
- System Software — sits between hardware and application software and manages resources. Key examples: Operating Systems (Windows, Linux, Android), device drivers, firmware, and utility programs (antivirus, disk tools).
- Application Software — programs that perform user-oriented tasks. Can be general-purpose (word processors, spreadsheets, browsers) or domain-specific (CAD, hospital management systems).
- Programming Software / Development Tools — tools used to create other software: compilers, interpreters, assemblers, linkers, debuggers, and IDEs.
Operating System (OS) — main functions
- Process Management: creates, schedules and terminates processes; provides multitasking.
- Memory Management: allocates and deallocates memory, provides virtual memory.
- File System: organizes files and directories, manages storage permissions.
- Device Management: controls device drivers and I/O operations.
- User Interface: command-line or graphical interfaces for user interaction.
- Security & Access Control: authentication, authorization, and protection mechanisms.
Translators
- Assembler: converts assembly language to machine code.
- Compiler: converts high-level language to machine code (usually creates an executable).
- Interpreter: directly executes high-level code line-by-line without producing a separate executable.
Software Distribution & Licensing — common types: proprietary (closed-source), open-source (code available), freeware (free to use), shareware (trial-based).
Quality & Measurement (brief) — software quality is tracked by measures such as defect density, reliability (MTBF/MTTR), and availability. Good design, testing and maintenance improve these metrics.
Relationship diagram (conceptual): Hardware <-- Firmware <-- Device Drivers <-- Operating System <-- Application Software. Programming tools are used alongside to build applications and system software.
Why it matters (real-life impact): Software controls phones, ATMs, medical devices, automobiles, and enterprise systems. Choice and design of software determine usability, performance, security and maintainability.
- Operating Systems: Microsoft Windows, Ubuntu (Linux), Android, iOS
- Application Software: Microsoft Word (word processor), Microsoft Excel (spreadsheet), Google Chrome (web browser), Adobe Photoshop (image editor)
- Domain-specific Applications: AutoCAD (design), Tally (accounting), LMS like Moodle (education)
- Programming Tools: GCC (compiler), Python Interpreter, Visual Studio Code (IDE)
- System Utilities: Antivirus (Windows Defender), Disk Defragmenter, File Compression tools (7-Zip)
- \[Defect density = Number of defects / Size of software (KLOC) e.g.\]\[defects per KLOC\]
- \[MTBF (Mean Time Between Failures) = Total operational time / Number of failures\]
- \[Availability = MTBF / (MTBF + MTTR) where MTTR = Mean Time To Repair\]
- \[Memory conversion: 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB (binary convention often used in OS contexts)\]
Operating System (OS) Functions and Types
Operating System (OS) Functions and Types
Key Point: CPU Utilization (%) = (CPU busy time / Total elapsed time) × 100
Overview: An Operating System (OS) is system software that manages computer hardware and provides services to application programs and users. It acts as an intermediary between users/applications and the hardware.
Major Functions:
- Process Management: Creates, schedules and terminates processes; handles CPU scheduling and context switching. Ensures fair CPU allocation and concurrency control.
- Memory Management: Allocates and deallocates primary memory (RAM) for processes, manages virtual memory, paging and segmentation to ensure efficient use and protection of memory.
- File System Management: Organizes, stores and retrieves files; provides directory structures, file permissions, and disk management.
- Device (I/O) Management: Controls and coordinates input/output devices using device drivers and buffering, caching, spooling.
- Resource Allocation: Allocates CPU, memory, storage and I/O devices among competing processes and users.
- User Interface: Provides CLI (command-line) or GUI (graphical) for users to interact with the system.
- Security and Protection: Authenticates users, enforces access control, protects data and resources from unauthorized access.
- Error Detection and Handling: Monitors system for errors (hardware/software) and takes corrective actions or logs errors for diagnosis.
- Accounting and Performance Monitoring: Keeps usage records for billing, auditing and performance tuning.
- Networking: Provides network services and protocols when connected to other systems (in network OS or distributed environments).
Common OS Services (how students see them): program execution, I/O operations, file manipulation, communication (IPC), background services/daemons.
Types of Operating Systems:
- Single-user, Single-tasking OS: Supports one user and one program at a time (e.g., early MS-DOS).
- Single-user, Multi-tasking OS: Single user runs multiple applications concurrently using CPU scheduling (e.g., Windows, macOS).
- Multi-user OS: Multiple users share system resources simultaneously with isolation (e.g., Unix/Linux servers, Windows Server).
- Batch OS: Executes batches of jobs without interaction; used in early mainframes.
- Time-sharing / Multitasking OS: Provides rapid switching among users/tasks to give interactive response (e.g., university time-sharing systems, modern desktops).
- Real-time OS (RTOS): Provides guaranteed response times for critical tasks (hard RTOS for strict deadlines, soft RTOS for less strict). Used in medical devices, industrial controllers (e.g., VxWorks, FreeRTOS).
- Distributed OS: Manages a group of independent computers and makes them appear as a single coherent system (e.g., systems using distributed file systems).
- Network OS: Provides services to computers connected on a network, focusing on file and printer sharing and security (e.g., Novell NetWare historically, Windows Server).
- Embedded OS: Small, specialized OS for devices (microwaves, routers). Often real-time and resource-constrained (e.g., embedded Linux, RTOS variants).
- Mobile OS: Optimized for phones and tablets (e.g., Android, iOS) with touch interfaces, power and network management.
How functions map to real life: When you open a browser, the OS loads the program into memory (memory management), creates a process (process management), gives the process CPU time (scheduling), allows the program to read/write files (file system), and sends/receives network packets (networking). The OS also checks your login and enforces permissions (security).
Design goals: efficiency (high throughput, low response time), fairness, reliability, portability and security.
- Windows 10 / 11 (single-user, multi-tasking OS with GUI and wide driver support)
- Linux (multi-user, multitasking; used on servers, desktops and embedded systems)
- Android (mobile OS built on Linux kernel for smartphones and tablets)
- iOS (mobile OS with strict sandboxing and resource management)
- FreeRTOS / VxWorks (real-time OS used in embedded controllers, robots, avionics)
- Embedded OS in a microwave or washing machine (runs limited, dedicated tasks)
- \[CPU Utilization (%) = (CPU busy time / Total elapsed time) × 100\]
- \[Turnaround Time = Completion Time − Arrival Time\]
- \[Waiting Time = Turnaround Time − Burst (Execution) Time\]
- \[Response Time = Time of first response − Arrival Time\]
- \[Throughput = Number of processes completed / Time interval\]
- \[Effective Access Time (paging) ≈ (1 − p) × memory_access_time + p × page_fault_overhead (p = page fault rate)\]
Programming Languages and Tools
Programming Languages and Tools
Key Point: Execution Time = Instruction Count × CPI × Clock Cycle Time
Overview
Programming languages are formal languages used to give instructions to computers. Tools around these languages (translators, IDEs, debuggers, build systems, version control, profilers, package managers) form the software toolchain that turns human-readable source code into running programs.
Levels of programming languages
- Machine language – binary instructions executed directly by the CPU (lowest level).
- Assembly language – mnemonic codes representing machine instructions; requires an assembler to convert to machine code.
- High-level languages – English-like syntax (C, Java, Python, JavaScript); easier to write and maintain; require translators (compiler/interpreter/JIT) to run on hardware.
Translators and execution models
- Assembler – converts assembly code to machine code.
- Compiler – translates entire source code into machine code or an intermediate form before execution (e.g., C -> object code; Java -> bytecode).
- Interpreter – executes source code line-by-line or statement-by-statement (e.g., Python interpreter).
- JIT (Just-In-Time) compiler – compiles parts of code at runtime for speed (used in modern JavaScript engines and Java HotSpot).
- Linker & Loader – linker combines object modules and libraries into an executable; loader places the executable into memory to run.
Common programming tools
- IDEs (Integrated Development Environments) – code editor, build/run, debugger, and other integrations (e.g., VS Code, Eclipse, Android Studio).
- Text editors – lightweight code editing (e.g., Sublime Text, Vim).
- Debuggers – step through code, inspect variables, set breakpoints (e.g., gdb)
- Version control – track changes and collaborate (e.g., Git).
- Build tools – automate compilation and packaging (e.g., make, gradle, Maven).
- Package managers – install and manage libraries (e.g., pip, npm).
- Profilers – measure performance hotspots (e.g., gprof, perf).
Programming paradigms – different languages support different styles:
- Procedural (C): step-by-step routines.
- Object-oriented (Java, C++): objects and classes.
- Functional (Haskell, parts of Python): functions as first-class values, immutability.
- Declarative (SQL): describe what, not how.
Compiled vs Interpreted — practical differences
- Compiled: faster execution, separate build step, produces standalone binaries (C, C++).
- Interpreted: faster edit-run cycle, easier debugging, cross-platform if interpreter exists (Python, JavaScript).
- Hybrid: compile to intermediate bytecode, then interpret or JIT (Java, .NET).
Choosing a language & tools
Choose based on intended platform (embedded, web, mobile), performance needs, library support, developer productivity, ecosystem and tooling (IDE, debuggers, package managers), and learning curve.
Small code examples
Different languages, same task (print 'Hello'):
/* C */
#include <stdio.h>
int main(){ printf("Hello"); return 0; }
# Python
print("Hello")
// JavaScript
console.log("Hello")
How source becomes a running program (typical compiled flow)
- Write source code (.c, .java, .py)
- Compile (C) or translate to bytecode (Java) or interpret (Python)
- Link libraries to create an executable
- Loader places executable into memory and starts execution
Performance & measurement basics
When evaluating languages and compilers you often measure execution time, memory use and throughput. Tools (profilers) help find slow functions that compilers or algorithms can optimize.
Summary
Programming languages are the human-facing notation for algorithms; tools (translators, IDEs, debuggers, build systems, version control, package managers, profilers) are essential to develop, test, and deliver software. Understanding the language level, translation flow, and appropriate tools is key to building reliable and efficient software.
- Mobile app: An Android app is typically written in Kotlin/Java using Android Studio (IDE). Code is compiled to bytecode and then to native code; build tools (Gradle) and debuggers are used during development.
- Web page behaviour: Front-end logic uses JavaScript executed by the browser's JS engine (interpreter + JIT). Developers use browsers' devtools to debug and profile.
- Data analysis: A data scientist writes Python code using libraries (NumPy, pandas). The Python interpreter and package manager (pip) manage execution and dependencies.
- Embedded systems: Microcontroller firmware is often written in C/Assembly and compiled with cross-compilers; the assembler, linker, and loader produce a binary flashed to hardware.
- Scripting & automation: System administrators write Bash or Python scripts that are interpreted directly to automate backups, deployments, and monitoring.
- Web backend: A server-side app may be written in Java (compiled to bytecode, run on JVM) or Node.js (JavaScript interpreted/JIT); build, test and CI/CD pipelines automate deployment.
- \[Execution Time = Instruction Count × CPI × Clock Cycle Time\]
- \[Throughput = Number of Instructions (or Tasks) / Time\]
- \[Speedup = Time_before_optimization / Time_after_optimization\]
- \[Productivity (simple) = Lines of Code (LOC) / Person‑month (useful as rough metric\]\[not definitive)\]
Translators and Execution Process
Translators and Execution Process
Key Point: Total time (compiled, run n times) = T_compile + n * T_run
Overview
A translator is a program that converts source programs written in a high-level or low-level human-readable language into machine code or an intermediate form that a computer can execute. The execution process describes the sequence of steps from writing source code to running the program on the CPU.
Types of Translators
- Assembler: Converts assembly language (mnemonics) into machine code (binary). Produces object code and typically uses a symbol table.
- Compiler: Translates the entire high-level source program into object or machine code (or intermediate code) before execution. Common example: C, C++ compilers.
- Interpreter: Reads, translates, and executes source code statement-by-statement at runtime. Common example: Python interpreter.
- Hybrid/Bytecode Translators: Some languages (e.g., Java) compile source to an intermediate bytecode, then a virtual machine (JVM) interprets or JIT-compiles that bytecode to native code.
Phases of a Compiler
A typical compiler works in several phases (each may be separate modules):
- Lexical Analysis — tokenizes the character stream into tokens (identifiers, keywords, literals).
- Syntax Analysis (Parsing) — checks token sequences against grammar and builds a parse tree or abstract syntax tree (AST).
- Semantic Analysis — checks types, scope rules, and other language-specific constraints; builds/upgrades symbol table.
- Intermediate Code Generation — produces an intermediate representation (IR) that is machine-independent.
- Code Optimization — improves IR to run faster or use less memory (loop optimizations, dead-code elimination).
- Code Generation — translates optimized IR into target machine code.
- Assembly/Linking — assembler produces object files; linker combines object files and libraries to form an executable.
- Error Handling — reports lexical, syntax, semantic, and runtime errors (some at compile-time, others at run-time).
Interpreter Execution Process
An interpreter typically performs these steps repeatedly at runtime: reads one statement, parses it, evaluates/executes it, and moves to the next statement. Interpreters often include a read–eval–print loop (REPL) for interactive use.
Linker and Loader
- Linker: Resolves symbolic references between object files and libraries and produces a single executable or an executable image.
- Loader: Loads the executable image into memory, sets up runtime environment (stack, heap, initial registers), and transfers control to the program's entry point.
Virtual Machines and JIT
Languages like Java compile to bytecode executed by a virtual machine (JVM). Modern VMs use Just-In-Time (JIT) compilation to convert frequently used code paths at runtime into native machine code for better performance.
Typical End-to-End Execution Flow
- Write source code (editor).
- Use a translator (compiler/assembler) to produce object code or bytecode.
- Link object files and libraries to produce an executable (linker).
- Loader loads the executable into memory and prepares the runtime environment.
- CPU executes instructions; OS provides services (I/O, scheduling, memory protection).
Key Differences — Compilers vs Interpreters (summary)
- Compiler: translates whole program first, faster execution later, compile-time error detection.
- Interpreter: translates & executes line-by-line, slower per run, good for scripting and rapid testing, errors reported at runtime when reached.
Practical Considerations
Choosing between compilation and interpretation depends on performance needs, development speed, portability, and ease of debugging. Hybrid approaches (bytecode + VM + JIT) combine portability with good runtime performance.
- C program: source.c -> gcc compiles to object code (.o) -> linker creates executable -> loader loads and CPU executes.
- Java program: MyClass.java -> javac compiles to MyClass.class (bytecode) -> JVM interprets or JIT-compiles bytecode to native code -> program runs on any platform with a JVM.
- Python script: script.py -> Python interpreter reads and executes statements directly (or compiles to temporary bytecode .pyc internally), ideal for quick testing and scripting.
- Assembly: prog.asm -> assembler converts to machine code/object file -> linker/loader create and run executable (used in embedded systems for direct hardware control).
- JavaScript in browser: JS engine (e.g., V8) parses and compiles/optimizes code at runtime using JIT for fast web application execution.
- \[Total time (compiled\]\[run n times) = T_compile + n * T_run\]
- \[Total time (interpreted\]\[run n times) = n * (T_translate_per_run + T_run_per_run)\]
- \[Interpretation is advantageous when: n*(T_translate_per_run) + n*T_run < T_compile + n*T_run => n*T_translate_per_run < T_compile (i.e.\]\[for very small n\]\[interpretation may be faster overall)\]
- \[Execution Time = CPU Time + I/O Time + Wait Time (conceptual breakdown used when measuring performance)\]
- \[Speedup = Old time / New time (used to quantify improvement after optimization or JIT)\]
Booting Process
Booting Process
Key Point: Total Boot Time = POST time + Bootloader time + Kernel init time + Service init time
Booting Process is the sequence of steps a computer performs when it is switched on or restarted to load the operating system (OS) and make the machine ready for use. Booting brings hardware and software from a powered-off or inactive state to a running state.
Types of Booting
- Cold Boot (Hard Boot): Powering the computer on from a completely off state. All startup steps run (power applied → firmware → OS).
- Warm Boot (Soft/Restart): Restarting the computer without cutting power (e.g., using Restart). Some hardware initialization may be skipped or optimized.
Step-by-step Sequence
- Power on and firmware initialization: The motherboard firmware (BIOS or UEFI) receives power, initializes CPU, memory, chipset and basic peripherals.
- POST (Power-On Self-Test): Diagnostic tests check CPU, RAM, keyboard, display and essential devices. Errors are reported via beep codes or messages.
- Firmware device detection and boot order: BIOS/UEFI scans storage devices (HDD/SSD/USB/CD) in configured order to find a bootable device.
- Bootstrap loader / Boot manager: The firmware loads the bootloader from the disk’s boot record (MBR on legacy BIOS, EFI system partition on UEFI). Examples: GRUB (Linux), Windows Boot Manager.
- Bootloader actions: Present menu (if multi-OS), choose kernel/OS image, load the OS kernel into memory, and transfer control to it.
- Kernel initialization: Kernel initializes hardware drivers, sets up memory management, mounts the root filesystem, and starts system services.
- Start-up services and user environment: Init systems (systemd, init, launchd) start background services and login managers, leading to a login screen or desktop environment.
BIOS vs UEFI (key differences)
- BIOS: Older firmware, uses MBR (Master Boot Record) with a 512-byte boot sector and limits such as 2 TB drives.
- UEFI: Modern firmware, uses GPT (GUID Partition Table), supports larger disks, secure boot, graphical interfaces, and faster boot times.
Common Concepts
- MBR vs GPT: MBR contains a small boot program and partition table; GPT is more robust and supports more partitions and larger drives.
- Boot order: The sequence of devices firmware checks to find an OS (e.g., USB → DVD → SSD).
- Secure Boot: UEFI feature that checks digital signatures of boot components to prevent unauthorized code.
Why boot stages matter
Understanding boot stages helps diagnose problems (e.g., stuck at POST, missing bootloader), optimize boot time (faster storage, fewer startup services), and secure the system (enable Secure Boot).
- Laptop cold boot: Press power button → firmware runs POST → firmware loads bootloader from SSD → bootloader loads OS kernel → login screen appears.
- Restart after update: System downloads update and triggers warm boot. Firmware may skip some deep hardware init, and system boots back into the new kernel or patched files.
- USB boot to install OS: Set USB as first boot device in firmware → firmware loads installer bootloader from USB → OS installation environment starts.
- Embedded device (e.g., router): Minimal bootloader in flash initializes network chipset and loads the firmware image directly into memory.
- \[Total Boot Time = POST time + Bootloader time + Kernel init time + Service init time\]
- \[Boot Speedup Ratio ≈ HDD boot time / SSD boot time (typical values: 2–5× faster with SSD depending on system and services)\]
- \[Service Load Percentage = (Time spent initializing service X / Total Boot Time) × 100%\]
Algorithms and Flowcharts (Introductory)
Algorithms and Flowcharts (Introductory)
Key Point: Sum of first n natural numbers: S = n(n + 1) / 2 — useful for algorithms that add 1..n.
What is an algorithm? An algorithm is a finite, ordered set of well-defined steps that describes how to perform a task or solve a problem. Each step must be clear and unambiguous. Algorithms are independent of programming language — they are the logical recipe you follow to reach a solution.
Key characteristics of a good algorithm
- Finiteness: It must terminate after a finite number of steps.
- Definiteness: Each step must be precisely stated.
- Input: Zero or more inputs may be specified.
- Output: At least one output should be produced.
- Effectiveness: Steps must be basic enough to be carried out.
Basic algorithm design steps
- Understand the problem and identify inputs and outputs.
- Break the problem into smaller subproblems if possible.
- Design a step-by-step procedure (use pseudocode or flowchart).
- Verify correctness with examples (trace execution by hand).
- Refine for clarity and efficiency.
Pseudocode (simple conventions)
- Use readable statements:
SET total = 0,IF condition THEN,WHILE condition DO,FOR i = 1 TO n DO,PRINT result. - Indent blocks to show nesting.
What is a flowchart? A flowchart is a graphical representation of an algorithm using standard symbols connected by arrows showing the flow of control. Flowcharts make logic easier to visualize and debug.
Common flowchart symbols
- Oval (Terminator): Start/End
- Rectangle (Process): Computation or assignment
- Parallelogram (Input/Output): Read or print values
- Diamond (Decision): Conditional branch (yes/no)
- Arrow: Flow of control
- Circle (Connector): Connects separated parts of a chart
How to convert an algorithm into a flowchart
- Identify start and end points.
- List the sequence of actions (input, processing, decision, output).
- Use the standard symbols to draw each action and connect them with arrows in the correct order.
- Test the flowchart with sample data to ensure it handles all cases (including edge cases).
Simple example (find maximum of three numbers)
ALGORITHM MaxOfThree(A, B, C)
IF A >= B AND A >= C THEN
MAX = A
ELSE IF B >= A AND B >= C THEN
MAX = B
ELSE
MAX = C
END IF
PRINT MAX
END
You can represent the above using a flowchart: Start → Input A,B,C → Decision A>=B? → nested decision A>=C? etc. → Output MAX → End.
Correctness and basic efficiency
- Correctness: Prove or validate that the algorithm produces the expected output for all valid inputs.
- Efficiency (introductory view): Compare algorithms by how many basic steps they do. Common informal measures: constant time O(1), linear time O(n), logarithmic O(log n).
When to use algorithms vs. flowcharts
- Use algorithms/pseudocode for precise, language-independent instructions and for implementation planning.
- Use flowcharts for visualizing control flow, teaching, debugging, or presenting logic to non-programmers.
Tips for students
- Trace algorithms by hand using sample data to check every path.
- Keep flowcharts simple — one level per chart; use connectors for large charts.
- Use meaningful variable names and comments in pseudocode.
- Recipe for baking a cake: a step-by-step algorithm (gather ingredients → mix → bake → cool → serve). Represented as a flowchart with inputs (ingredients), processes (mixing, baking) and decisions (is it baked?).
- Making tea: (boil water → add tea leaves → steep → strain → serve). This is a linear algorithm with clear start/end.
- Checking a student's pass/fail: Input marks → IF marks >= 40 THEN print 'Pass' ELSE print 'Fail'. Representable with one decision diamond in a flowchart.
- Searching a name in an unsorted list (linear search): check each name one by one until found or list ends. Worst-case comparisons = n.
- Finding a word in a dictionary (binary search on a sorted list): repeatedly halve the search interval. Comparisons roughly log2(n) in the worst case.
- \[Sum of first n natural numbers: S = n(n + 1) / 2 — useful for algorithms that add 1..n.\]
- \[Linear search comparisons (worst-case) = n for n items.\]
- \[Binary search comparisons (worst-case) ≈ floor(log2 n) + 1 for n sorted items.\]
- \[Basic time-complexity categories (introductory): O(1) = constant time\]\[O(n) = linear time\]\[O(log n) = logarithmic time.\]
- \[Simple swap using a temporary variable: temp = a\]\[a = b\]\[b = temp.\]
Data Representation Basics
Data Representation Basics
Key Point: Positional value: value = Σ (d_i × r^i) where r = base (e.g., 2 for binary).
Computers store and process information using electrical states that are easiest represented as binary digits (bits). Data representation is the set of rules and formats used to encode numbers, characters, images, sound and other information into bits and bytes so that computers can store, transmit and operate on them.
Core concepts
- Bit and byte: 1 bit is a binary digit (0 or 1). 1 byte = 8 bits. Higher units: KB (1024 bytes), MB, GB, TB (powers of 1024 in computers).
- Positional (radix) notation: A number in base r uses digits d_n ... d_1 d_0 where value = Σ d_i × r^i. For binary (r=2), each bit has weight 2^i.
- Number systems: Common bases are decimal (base 10), binary (base 2), octal (base 8) and hexadecimal (base 16). Hex digits 10–15 are A–F.
- Binary fractions: Bits right of the binary point have weights 2^-1, 2^-2, ...; fractional conversion uses repeated multiply-by-2 method.
- Character encoding: Characters are represented by numeric codes. ASCII (7/8-bit) and Unicode (UTF-8/UTF-16) map characters to numeric values so text can be stored in bytes.
- Signed numbers: To represent negative integers, formats include sign–magnitude, ones' complement and two's complement. Two's complement is standard: it simplifies arithmetic and has a continuous range including negative numbers.
- Binary-coded decimal (BCD): Each decimal digit is stored in a fixed 4-bit nibble (e.g., decimal 9 = 1001). Useful in financial/decimal-precise applications.
- Floating-point (approximate real numbers): IEEE 754 format stores sign, biased exponent and mantissa (fraction). Value (normalized) = (-1)^sign × 1.fraction × 2^(exponent − bias).
Why this matters (practical implications)
- Storage size and precision: choice of representation affects how much memory data needs and how precisely numbers are stored (e.g., integer overflow, floating point rounding).
- Interoperability: using standard encodings (ASCII/Unicode, IEEE 754) ensures different systems interpret data the same way.
- Human interfaces: hexadecimal is commonly used for compact display of binary (e.g., color codes, memory addresses).
Important conversions and methods (brief)
- Decimal → Binary (integer): divide-by-2 repeatedly, record remainders (LSB first).
- Binary → Decimal: sum bit × 2^position.
- Decimal fraction → Binary fraction: multiply fraction by 2 repeatedly; integer parts form bits (stop when fraction becomes 0 or after needed precision).
- Binary ↔ Hexadecimal: group bits in nibbles of 4 (binary to hex) or expand hex digits to 4 bits (hex to binary).
- Two's complement (n bits): to get negative of a number, invert all bits (ones' complement) and add 1.
These basic rules let computers encode everything from text and numbers to images and sound as sequences of bits.
- Decimal to binary (156): 156 ÷ 2 = 78 r0, 78 ÷ 2 = 39 r0, 39 ÷ 2 = 19 r1, 19 ÷ 2 = 9 r1, 9 ÷ 2 = 4 r1, 4 ÷ 2 = 2 r0, 2 ÷ 2 = 1 r0, 1 ÷ 2 = 0 r1 → read remainders up = 10011100₂.
- Binary to decimal (101101₂): 1×2^5 + 0×2^4 + 1×2^3 + 1×2^2 + 0×2^1 + 1×2^0 = 32 + 0 + 8 + 4 + 0 + 1 = 45₁₀.
- Hex and color codes: HTML color #1A8FEE → 1A (hex) = 00011010 (red), 8F = 10001111 (green), EE = 11101110 (blue) as 24-bit RGB values.
- Character encoding: 'A' in ASCII = 65₁₀ = 01000001₂ stored in one byte. Unicode extends this to represent characters of many languages (e.g., 'अ' has a Unicode code point 0x0905).
- Two's complement negative (8-bit) example: represent -5. +5 = 00000101, invert → 11111010, add 1 → 11111011; so -5 = 11111011₂. Range for 8-bit two's complement: -128 to +127.
- Binary fraction: convert 0.625 to binary: 0.625×2=1.25 (bit 1), 0.25×2=0.5 (bit 0), 0.5×2=1.0 (bit 1) → 0.101₂ = 0.625₁₀.
- \[Positional value: value = Σ (d_i × r^i) where r = base (e.g., 2 for binary).\]
- \[Decimal range for unsigned n-bit number: 0 to 2^n − 1.\]
- \[Two's complement range for n bits: −2^(n−1) to 2^(n−1) − 1.\]
- \[Two's complement (negation): negative(x) = (2^n − x) or invert bits of x then add 1.\]
- \[Floating-point (IEEE 754 normalized): value = (−1)^sign × 1.fraction × 2^(exponent − bias)\]\[For single-precision bias = 127\]\[for double-precision bias = 1023.\]
- \[Memory units (binary): 1 KB = 1024 B, 1 MB = 1024 KB = 1024^2 B, 1 GB = 1024^3 B\]\[etc.\]
Key Concepts
- Computer System
- An integrated set of hardware, software and data that accepts input, processes it and produces output.
- Hardware
- The physical components of a computer system that you can touch.
- Software
- A collection of programs and instructions that tell hardware what to do.
- Firmware
- Permanent software programmed into read-only memory that provides low-level control of hardware.
- Central Processing Unit (CPU)
- The main processing unit that performs instructions of programs, controlling and coordinating tasks.
- Arithmetic Logic Unit (ALU)
- Part of the CPU that performs arithmetic (add, subtract) and logical (AND, OR) operations.
- Control Unit (CU)
- CPU component that fetches instructions, decodes them and directs other parts of the computer.
- Memory
- Storage locations used to hold data and instructions temporarily or permanently.
- Primary Memory (RAM)
- Volatile memory used by the CPU to store data and programs currently in use.
- Read-Only Memory (ROM)
- Non-volatile memory containing permanent instructions that cannot be easily altered.
- Secondary Storage
- Non-volatile devices used to store data long-term and persistently.
- Cache Memory
- Small, very fast memory placed between CPU and RAM to speed up access to frequently used data.
- Bus
- A communication pathway that transfers data, addresses and control signals between components.
- Input Device
- Hardware used to provide data and control signals to a computer.
- Output Device
- Hardware that presents processed data from the computer to the user.
- Operating System
- System software that manages hardware resources and provides common services for applications.
- Application Software
- Programs designed to perform specific tasks for users, built on top of the OS.
- Programming Language
- A formal language used to write programs that instruct the computer to perform tasks.
- Compiler
- A translator that converts entire source code from a high-level language into executable machine code.
- Algorithm
- A step-by-step procedure or set of rules to solve a problem or perform a computation.
Practice Questions
-
Differentiate between the Control Unit (CU) and the Arithmetic Logic Unit (ALU) of a CPU. / CPU की कंट्रोल यूनिट (CU) और अरिथमेटिक लॉजिक यूनिट (ALU) में अंतर बताइए।
Show answer
The Control Unit directs and coordinates operations by interpreting instructions and generating control signals, while the ALU performs the actual arithmetic (add, subtract) and logical (AND, OR, comparison) operations. / कंट्रोल यूनिट निर्देशों की व्याख्या करके और नियंत्रण संकेत उत्पन्न करके कार्यों का निर्देशन व समन्वय करती है, जबकि ALU वास्तविक अंकगणितीय (जोड़, घटाव) और तार्किक (AND, OR, तुलना) संक्रियाएँ करती है।
-
Why is RAM called volatile memory while ROM is non-volatile? / RAM को वोलाटाइल मेमोरी और ROM को नॉन-वोलाटाइल क्यों कहा जाता है?
Show answer
RAM is volatile because it loses all stored data when power is switched off, whereas ROM is non-volatile because it retains its data (such as firmware) even without power. / RAM वोलाटाइल है क्योंकि बिजली बंद होने पर इसका सारा डेटा मिट जाता है, जबकि ROM नॉन-वोलाटाइल है क्योंकि यह बिजली के बिना भी अपना डेटा (जैसे फर्मवेयर) बनाए रखती है।
-
Explain the four stages of the instruction (fetch-decode-execute) cycle in the von Neumann model. / वॉन न्यूमैन मॉडल में निर्देश (फेच-डिकोड-एग्जीक्यूट) चक्र के चार चरण समझाइए।
Show answer
Fetch retrieves the instruction from memory into the instruction register using the PC; Decode interprets the instruction and identifies operands; Execute performs the operation in the ALU; Store/Write-back saves the result to a register or memory and the PC is updated. / फेच में PC का उपयोग करके निर्देश मेमोरी से इंस्ट्रक्शन रजिस्टर में लाया जाता है; डिकोड में निर्देश की व्याख्या होती है व ऑपरेंड पहचाने जाते हैं; एग्जीक्यूट में ALU संक्रिया करता है; स्टोर/राइट-बैक में परिणाम रजिस्टर या मेमोरी में सहेजा जाता है और PC अद्यतन होता है।
-
What is the von Neumann bottleneck and why does it occur? / वॉन न्यूमैन बॉटलनेक क्या है और यह क्यों होता है?
Show answer
It is the limitation in which a single shared memory and bus restrict how fast instructions and data can move between the CPU and memory, because both must travel over the same path. / यह वह सीमा है जिसमें एक साझा मेमोरी और बस इस बात को सीमित कर देती है कि CPU और मेमोरी के बीच निर्देश व डेटा कितनी तेज़ी से जा सकते हैं, क्योंकि दोनों को एक ही मार्ग से गुजरना पड़ता है।
-
A CPU has a clock rate of 2 GHz. Calculate its clock cycle time. / एक CPU की क्लॉक दर 2 GHz है। इसका क्लॉक चक्र समय निकालिए।
Show answer
Cycle time = 1 / Clock rate = 1 / (2 x 10^9) = 0.5 nanoseconds. / चक्र समय = 1 / क्लॉक दर = 1 / (2 x 10^9) = 0.5 नैनोसेकंड।
-
Arrange registers, RAM, cache and secondary storage in order of decreasing speed and justify. / रजिस्टर, RAM, कैश और सेकेंडरी स्टोरेज को घटती गति के क्रम में रखिए और औचित्य दीजिए।
Show answer
Order: Registers > Cache > RAM > Secondary storage; speed decreases down the memory hierarchy while capacity increases and cost per byte decreases, balancing performance with cost. / क्रम: रजिस्टर > कैश > RAM > सेकेंडरी स्टोरेज; मेमोरी पदानुक्रम में नीचे जाने पर गति घटती है जबकि क्षमता बढ़ती है और प्रति बाइट लागत घटती है, जो प्रदर्शन और लागत में संतुलन बनाता है।
-
Classify the following as system or application software: operating system, web browser, device driver, spreadsheet. / निम्नलिखित को सिस्टम या एप्लिकेशन सॉफ्टवेयर में वर्गीकृत कीजिए: ऑपरेटिंग सिस्टम, वेब ब्राउज़र, डिवाइस ड्राइवर, स्प्रेडशीट।
Show answer
System software: operating system and device driver (they manage hardware and provide services); Application software: web browser and spreadsheet (they perform user-specific tasks). / सिस्टम सॉफ्टवेयर: ऑपरेटिंग सिस्टम और डिवाइस ड्राइवर (ये हार्डवेयर प्रबंधित करते हैं और सेवाएँ देते हैं); एप्लिकेशन सॉफ्टवेयर: वेब ब्राउज़र और स्प्रेडशीट (ये उपयोगकर्ता-विशिष्ट कार्य करते हैं)।
-
Why does a supercomputer use FLOPS rather than MIPS as a performance measure? / सुपरकंप्यूटर प्रदर्शन माप के रूप में MIPS के बजाय FLOPS का उपयोग क्यों करता है?
Show answer
Supercomputers are used mainly for scientific simulations involving heavy floating-point calculations, so FLOPS (floating-point operations per second) measures their relevant throughput, whereas MIPS counts general instructions and is not a reliable measure for such workloads. / सुपरकंप्यूटर मुख्यतः भारी फ्लोटिंग-पॉइंट गणनाओं वाले वैज्ञानिक सिमुलेशन के लिए उपयोग होते हैं, इसलिए FLOPS (प्रति सेकंड फ्लोटिंग-पॉइंट संक्रियाएँ) उनकी प्रासंगिक क्षमता मापता है, जबकि MIPS सामान्य निर्देश गिनता है और ऐसे कार्यों के लिए विश्वसनीय माप नहीं है।
Related Laws & Principles
Explore allFoundational laws & principles connected to this chapter — tap to open in the Laws Explorer.