← Back to Home
Module 2: Computer Hardware and OS
Learning Objectives
- Understand the fundamental components of computer hardware
- Explain the role of the operating system in a computer system
- Describe the interaction between hardware and operating systems
- Identify common hardware components and their functions
- Understand basic operating system processes and resource management
- Explain the memory hierarchy and its impact on program performance
- Describe how the operating system manages processes and threads
- Understand the role of system calls in application development
- Explain the principles of virtualization and containerization
- Identify performance bottlenecks in hardware and software interactions
Introduction to Computer Hardware
Computer hardware refers to the physical components that make up a computer system. These components work together to process, store, and transmit data, enabling the computer to function.
In this module, we'll explore the major hardware components, their roles, and how they interact with the operating system to create a functioning computer system.
Core Hardware Components
Central Processing Unit (CPU)
The CPU is the brain of the computer, responsible for executing instructions and performing calculations. Modern CPUs contain multiple cores, allowing for parallel execution of tasks.
- Instruction Cycle: Fetch, decode, execute, store
- CPU Cache: L1, L2, and L3 caches provide fast access to frequently used data
- Clock Speed: Measured in GHz, indicates how many cycles per second
- Architecture: CISC vs. RISC design approaches
Memory (RAM)
Random Access Memory provides temporary, high-speed storage for data that the CPU needs to access quickly. RAM is volatile, meaning its contents are lost when power is turned off.
- Types: DDR4, DDR5, etc.
- Capacity: Measured in gigabytes (GB)
- Access Time: Typically measured in nanoseconds
- Role: Stores currently running programs and their working data
Storage Devices
These provide persistent storage for the operating system, applications, and user data.
- Hard Disk Drives (HDD): Magnetic storage, slower but more affordable for large capacities
- Solid State Drives (SSD): Flash memory-based storage, faster but more expensive
- NVMe: Interface protocol designed to accelerate the transfer of data between SSDs and a computer's CPU
- Access Times: Milliseconds (HDD) vs. microseconds (SSD)
Motherboard
The main circuit board that connects all components together, providing pathways for data transfer.
- Chipset: Controls communication between CPU, memory, and peripherals
- Bus: Pathway for data transfer between components
- Form Factors: ATX, Micro-ATX, Mini-ITX, etc.
- Expansion Slots: PCIe slots for graphics cards, network cards, etc.
Operating System Fundamentals
The operating system (OS) is system software that manages computer hardware, software resources, and provides services for computer programs.
Core Functions
- Process Management: Creating, scheduling, and terminating processes
- Memory Management: Allocating and deallocating memory for processes
- File System Management: Organizing and controlling access to files
- Device Management: Controlling input/output operations with peripherals
- Security: Protecting system resources and user data
Process and Thread Management
Processes are instances of executing programs, while threads are the units of execution within a process.
- Process States: New, Ready, Running, Waiting, Terminated
- Context Switching: Saving and restoring process state when switching between processes
- Scheduling Algorithms: First-Come-First-Served, Round Robin, Priority-based, etc.
- Multi-threading: Concurrent execution of multiple threads within a process
Memory Hierarchy
Memory is organized in a hierarchy, with faster but smaller storage at the top and slower but larger storage at the bottom.
- Registers: Fastest memory, inside the CPU
- Caches (L1, L2, L3): Small, fast memory between CPU and RAM
- Main Memory (RAM): Primary working memory
- Secondary Storage: Hard drives, SSDs
- Tertiary Storage: Tape drives, optical media
Understanding this hierarchy is crucial for optimizing software performance.
Hardware-Software Interaction
System Calls
System calls are the interface between user applications and the operating system kernel, allowing applications to request services from the OS.
- Types: Process control, file management, device management, information maintenance, communication
- Implementation: Typically involves a mode switch from user mode to kernel mode
- Examples: open(), read(), write(), fork(), exec()
Virtualization
Virtualization allows multiple operating systems to run on the same physical hardware simultaneously.
- Virtual Machines: Complete abstraction of physical hardware
- Containers: Lightweight virtualization at the OS level
- Hypervisors: Software that creates and runs virtual machines
- Benefits: Resource efficiency, isolation, flexibility
Performance Considerations
Understanding hardware-software interactions helps identify and resolve performance bottlenecks.
- I/O Bottlenecks: Slow disk access, network latency
- CPU Bottlenecks: Compute-intensive operations, inefficient algorithms
- Memory Bottlenecks: Insufficient RAM, excessive paging
- Optimization Techniques: Caching, parallel processing, asynchronous I/O
Resources
Guided project to explore hardware and operating system concepts.
Additional code-along exercises for this sprint.
Access the sprint challenge for this unit.