0% found this document useful (0 votes)
28 views51 pages

Introduction to Computer Systems

The document provides an overview of computer systems, detailing the interaction between hardware and software, the representation of information as bits, and the translation of programs into machine-readable formats. It also covers processor instruction execution, memory hierarchy, operating systems, and the representation of data at the machine level, including integer and floating-point representations. The importance of caches, memory management, and the role of operating systems in managing hardware resources and facilitating communication are emphasized.

Uploaded by

allahbuxdehpal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views51 pages

Introduction to Computer Systems

The document provides an overview of computer systems, detailing the interaction between hardware and software, the representation of information as bits, and the translation of programs into machine-readable formats. It also covers processor instruction execution, memory hierarchy, operating systems, and the representation of data at the machine level, including integer and floating-point representations. The importance of caches, memory management, and the role of operating systems in managing hardware resources and facilitating communication are emphasized.

Uploaded by

allahbuxdehpal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Lecture #1

Introduction to Computer Systems


Introduction to Computer Systems

 What is a Computer System?

 A computer system consists of hardware and software working together to


perform tasks.
 Hardware: Physical components (e.g., CPU, memory, storage).
 Software: Programs and data that tell the hardware what to do.
Information is Bits + Context
 What are Bits?
 Bit is short for binary digit, representing the smallest unit of data in a
computer.A bit can either be a 0 or a 1.
 Computers store and process everything (text, images, sounds) in the
form of bits.
 Context:
 gives meaning to bits. Without context, a series of bits is just
raw data.
 Example: The same sequence of bits can represent a number, a letter,
or an instruction depending on the [Link] interpret bits
differently based on the context provided by the software or the
program.
Programs are Translated into
Different Forms
 Source Code:
 Programs start as human-readable source code, written in programming
languages like Python, C++, Java, etc.
 Source code is understandable by humans but not directly by computers.
 Translation Process
 Compilers and Interpreters are programs that convert source code into
machine-readable formats.
 Compilers translate the entire program into machine code (binary)
before execution.
 Interpreters translate and execute the program line by line during
runtime
Forms of Program Translation

 Machine Code:
 Directly understandable by the computer's CPU.
 Composed entirely of bits (0s and 1s) representing instructions for the
hardware.
 Assembly Code:
 A low-level representation of machine code.
 Easier for humans to understand than raw binary, but still hardware-specific .
 Intermediate Code:
 Some languages (e.g., Java) use an intermediate form known as
bytecode, which is platform-independent and later interpreted by a
virtual machine.
Summary

 Computer systems process information in the form of bits, but context


determines how those bits are interpreted.
 Programs are written in human-friendly source code but need to be
translated by other programs (like compilers or interpreters) into forms
that the machine can understand, such as machine code or bytecode.
 This structure provides a comprehensive overview of key concepts such
as the binary representation of information and the process of
translating programs into machine-understandable forms.
Lecture#2
Introduction to Processor
Instruction Execution
 The Basics of Processor Instruction Execution
 Processors execute instructions stored in memory.
 The process involves fetching, decoding, executing ,and completing
instructions.
 Completion systems ensure instructions finish in the correct sequence.
Introduction to Processor
Instruction Execution
 Step #1 Instruction Fetch
1. CPU fetches instructions from memory.
2. The Program Counter (PC) holds the address of the next instruction.
3. Cache memory helps speed up the fetch process by storing frequently
used instructions.
 Step 2 – Instruction Decode
1. Decoding involves interpreting the binary instruction.
2. Opcode identifies the operation (e.g., ADD, SUB, LOAD).
3. Operands specify the data or memory locations needed for execution.
Introduction to Processor
Instruction Execution
 Step 3 – Execution
1. Arithmetic Logic Unit (ALU) performs arithmetic/logical operations.
2. Data moves between registers or memory.
3. Can involve computation, data movement, or control flow changes.
 Step 4 – Memory Access
1. For memory-related instructions, the CPU reads/writes data from/to
memory.
2. Efficient memory access is critical to performance (use of cache, register
files).
Introduction to Processor
Instruction Execution
 Step 5 – Write-back
1. The result of the execution is written back to registers or memory.
2. Ensures the data is ready for future instructions.
 Instruction Completion
1. Ensures that instructions complete in the correct order, even in out-of-
order execution.
2. Retirement is the process of finalizing and completing the instruction
cycle.
3. Completion systems handle dependencies between instructions to
maintain consistency.
Introduction to Processor
Instruction Execution
 Optimizing with Pipelining and Completion Systems
1. Pipelining allows overlapping of instruction execution stages, improving
efficiency.
2. Out-of-order execution improves speed, but completion systems ensure
instructions retire in order.
 Conclusion
 The Importance of Completion Systems
1. Completion systems ensure reliable execution even with complex
dependencies.
2. Understanding the instruction cycle helps in optimizing performance and
architecture design.
Introduction to Processor
Instruction Execution
Lecture#3
Introduction to Processors

 CPU (Processor): The central unit that executes instructions.


 Basic Functions: Fetch, decode, execute, and store instructions.
 Components: Arithmetic Logic Unit (ALU), Control Unit (CU), and
Registers.
 Instruction Cycle Overview
 Fetch: The processor retrieves an instruction from memory.
 Decode: The instruction is decoded to understand what action is
needed.
 Execute: The processor performs the required operation (e.g., math
calculation, data move).
 Store: The result is stored back into memory or registers.
Introduction to Processors

 memory Structure
1. Registers: Fast, small memory inside the CPU, storing immediate data
2. .RAM (Main Memory): Where instructions and data are stored temporarily
for quick access.
3. Cache: A small, faster memory closer to the CPU, stores frequently
accessed data.
 Instruction Fetch
1. Program Counter (PC): Holds the address of the next instruction.
2. Fetch Cycle: The processor reads the instruction stored at the memory
address from RAM or cache and loads it into the instruction register.
Introduction to Processors

 Instruction Decode
1. Control Unit (CU): Decodes the instruction fetched.
2. Opcode: The part of the instruction that specifies the operation to be
performed.
3. Operands: The data on which the operation is to be performed.
 Instruction Execution
1. ALU Operation: If the instruction involves arithmetic or logic
operations, the ALU executes it.
2. Data Move: If the instruction involves moving data (e.g., from memory
to a register), it is carried out.
Introduction to Processors

 Memory Hierarchy in Action


 Registers → L1 Cache → L2/L3 Cache → Main Memory (RAM) →
Secondary Storage: Show how the CPU moves through this hierarchy to
fetch and store data efficiently.
 Short summery
 This layout gives a structured overview on how processors read and
interpret instructions stored in memory.
Memory and Storage Hierarchy
The Role of Caches and Storage Devices
Memory and Storage Hierarchy

 The Importance of Caches


1. Caches are small, fast memory located close to the CPU.
2. They store frequently used data to reduce access time.
3. CPU speed far exceeds main memory, so caches bridge the speed gap
Cache Memory Basics

 Cache Memory Explained


1. L1 Cache: Closest to CPU,
smallest, fastest.
2. L2 Cache: Larger than L1, but
slower.L
3. 3 Cache: Shared between cores,
largest and slowest of the
caches.
How Cache Works

 Cache Operation
 Cache hit: Data is found in the
cache, providing fast access.
 Cache miss: Data is not in the
cache, requiring access from a
slower memory tier.
 Replacement policy:
Determines which data is
replaced when the cache is full.
Memory and Storage Hierarchy

 Storage Device Hierarchy


 Memory hierarchy is structured
by speed, cost, and capacity.
 Registers (fastest) → Cache →
Main Memory (RAM) →
Secondary Storage
(SSD/HDD).
 Tradeoff: Faster memory is
smaller and more expensive.
Types of Storage Devices

 Types of Storage Devices


1. RAM: Fast, volatile memory used
for immediate data.
2. Solid-State Drives (SSD): Fast,
non-volatile storage, uses flash
memory.
3. Hard Disk Drives (HDD): Slower,
mechanical storage, high
capacity.
4. Optical Drives, Flash Drives:
Additional long-term storage
options.
RAM vs. Storage

 Difference Between RAM


and Storage
1. RAM: Temporary storage for
data being used actively by the
CPU.
2. Storage (SSD/HDD): Long-term
storage for data not currently in
use.
3. Speed difference: RAM is
much faster than SSD/HDD.
Data Flow in the Hierarchy

 How Data Moves Through


the Hierarchy
1. CPU requests data → Check L1
Cache → If miss, check L2/L3 →
Check RAM → Check Storage
(SSD/HDD).
2. Data flows from slow storage to
faster memory as needed.
Balancing Speed and Capacity

 The Balance Between Speed


and Capacity
 Registers and Caches:
Extremely fast but small.
 RAM: Moderate speed,
moderate [Link]
(SSD/HDD): Large capacity,
slower speed.
 System designers must
balance cost, speed, and
capacity.
Summary

 Caches improve CPU performance by reducing memory access time.


 The memory hierarchy balances speed, capacity, and cost to optimize
performance.
 Each tier in the hierarchy serves a unique role in managing data.
Introduction to Operating Systems

 Definition of OS: The OS is a


software layer that manages
hardware resources and
provides an environment for
applications to run.
 Main Functions of OS:
 Hardware Management
 Network Communication
 Information Representation and
Manipulation
Operating System Hardware
Management
• Resource Management:CPU Management: Schedules tasks for
efficient use of processor time.
• Memory Management: Allocates and tracks RAM to ensure
applications run smoothly.
• Storage Management: Manages access to storage devices (HDD, SSD)
and file systems.
• I/O Device Management: Manages communication with peripherals
(e.g., printers, keyboards).
• Device Drivers: Interfaces between OS and hardware components.
System Communication via Networks

 Networking Role of OS:


•Facilitates system communication through network protocols and interfaces.
TCP/IP Stack: Provides reliable data transfer and routing between systems.
 Network Communication Process:
[Link] Transmission: OS packages data into packets for network transfer.
[Link]: Uses communication protocols (TCP, UDP) for transmission control.
[Link] and Switching: OS helps data travel efficiently between source
and destination using network hardware.
 OSI Model Layers:
•Physical, Data Link, Network, Transport, and Application layers.
Representing and Manipulating
Information
• Data Representation in OS:
• Binary Representation: OS handles data in binary (1s and 0s) at a low
level.
• File Systems: Represents data in a hierarchical structure (e.g., FAT, NTFS).
• Process Management: Handles program execution by managing processes
and threads.
• Data Manipulation:
• Memory Allocation: OS manages how data is stored in RAM for efficient
processing.
• File Manipulation: OS allows users to create, modify, and delete files.
• Input/Output Operations: Manages how data is read from or written to
storage devices or network interfaces.
Information Security and Error
Handling
• Security Management:
• User Authentication: Verifies users and controls access to system
resources.
• Data Encryption: Protects data during storage and transmission.
• Access Control: Manages permissions for accessing files and hardware.
• Error Handling:
• Detects and resolves hardware or software errors.
• Provides recovery mechanisms for failed processes or network interruptions.
 Summery
 OS as a Core Component
 The OS is central in managing hardware resources, enabling
communication across networks, and representing/manipulating
information for users and applications.
 Integration: Ensures smooth functioning of hardware and software,
providing a seamless user experience.
Title: Understanding Machine-Level
Representation of Programs and Data
Information Storage, Arithmetic, and Control in Computing
 Introduction
 Overview:Computers store and manipulate information at the binary
level using various encoding schemes.
 This presentation will explore how integers, floating-point numbers, and
programs are represented and manipulated at the machine level.
 We will cover:
 Integer representation and arithmetic
 Floating-point representation
 Historical context and program encoding
 Memory management, logical operations, and control flow
Information Storage: Basics

 Data Representation in Computers:


 At the most fundamental level, computers store information in binary format:
a series of 0s and 1s.
 Bit: The smallest unit of data (either 0 or 1).
 Byte: A group of 8 bits (e.g., 10101101).
 Memory: Stored in various types such as RAM (volatile), ROM (non-volatile),
and storage devices.
 Addressable Memory: Each memory location has a unique address, used to
access and store data.
Information Storage: Basics
Integer Representation: Binary,
Signed, and Unsigned

•Unsigned Integers:
•Represent only non-negative numbers.
•Binary representation: 0 and 1. Each bit doubles in value (e.g., 8-bit unsigned integer
can represent values from 0 to 255).

•Example:
•00000001 → 1
•11111111 → 255
Integer Representation: Binary,
Signed, and Unsigned
•Signed Integers:
•Represent both positive and negative numbers.
•Two's complement: Most common method to represent signed integers in modern
computers.
•Positive numbers are represented the same way as unsigned integers.
•Negative numbers are represented by taking the two's complement of their
absolute value.
•Example:

•5 → 00000101
•-5 → 11111011 (two's complement of 5: invert bits and add 1)
Integer Representation: Binary,
Signed, and Unsigned
• Key Considerations:
• The range of values a given integer can represent depends on the number of
bits used.
• Example: A 8-bit signed integer has a range of -128 to 127.
Integer Arithmetic

 Basic Operations:Addition, subtraction, multiplication, and division are


performed using integer representations.
 Overflow:Overflow occurs when a calculation exceeds the maximum or
minimum value representable by the data type.
 For example, adding two large positive integers might result in a number
too large to fit in an 8-bit integer.
 Example:Adding two 8-bit unsigned integers 200 + 100 results in 300,
but the maximum representable value is 255, causing overflow.
Integer Arithmetic

• Carry and Borrow:


• In addition and subtraction, carry (for addition) and borrow (for subtraction)
may propagate between bits.
• Carry: A situation where an operation results in a value that exceeds the
current bit's capacity and is carried over to the next higher bit.
• Signed vs Unsigned Arithmetic:
• For signed numbers, Two's complement is used for arithmetic operations.
Unsigned arithmetic simply performs bitwise addition/subtraction without
considering sign.
Floating-Point Representation

•Why Floating-Point?
•Used to represent real numbers (e.g., 3.14, -5.67) which may have fractional parts.
•Unlike integers, floating-point numbers can represent a large dynamic range of values,
both very small and very large.
•IEEE 754 Standard:
•The most widely used standard for floating-point representation.
•Single Precision (32 bits):
•1 bit for the sign (S), 8 bits for the exponent (E), and 23 bits for the fraction (F).
•The value of the number is represented as:
(−1)S×(1+fraction)×2(E−127)(-1)^S \times (1 + \text{fraction}) \times 2^{(E - 127)}
(−1)S×(1+fraction)×2(E−127)
•Exponent is stored with a bias of 127.
•Example: 3.14 in IEEE 754 single precision is stored as 0 10000000 10010001111010111000011.
Floating-Point Representation

•Double Precision (64 bits):


•1 bit for the sign, 11 bits for the exponent, and 52 bits for the fraction.
•This allows for more precision and a wider range of representable values compared
to single precision.
•Normalization:
•The exponent is adjusted so that the leading bit of the mantissa is always 1
(except for subnormal numbers).
Machine-Level Representation of
Programs (Historical Perspective)
•Early Days of Computing:
•The earliest computers used machine language, which is directly executed by the hardware.
Each instruction was represented in binary code.
•Example: The ENIAC (1945) used binary-coded decimal (BCD) for computation.
•Assembly Language:
•As programs became more complex, assembly languages were introduced to simplify machine
programming.
•Assembly languages use symbolic representations for instructions (e.g., MOV, ADD, SUB).
•High-Level Languages:
•To increase productivity and portability, high-level languages like C, FORTRAN, and Java were
developed in the 1950s and 60s.
•High-level code is compiled or interpreted into machine code (or assembly language) by a
compiler.
Program Encodings

• Instruction Set Architecture (ISA):Defines the set of instructions that


a processor can execute, along with their binary encodings.
• Examples:
• x86: A complex instruction set architecture (CISA) with a large number of
instructions.
• ARM: A reduced instruction set computing (RISC) architecture, known for
simpler instructions.
•Machine Code and Assembly:
•Machine code is the raw binary encoding of instructions.
•Assembly language provides human-readable mnemonics for these instructions.
•Example:
•Assembly: MOV AX, 5 (Move the value 5 into register AX).
•Machine Code: 10111000 00000101 (the actual binary encoding of the instruction).
Data Formats and Memory Layout

•Primitive Data Types:


•Integers, floating-point numbers, characters, and booleans are typically represented in a fixed-size
format in memory.
•Example: An integer (in C) might be stored as a 4-byte value.
•Arrays and Structs:
•Arrays are collections of contiguous memory locations, and each element can be accessed by an
index.
•Structs (in languages like C/C++) are complex data types that store a collection of different types.
•Memory Alignment:
•Alignment refers to ensuring that data types are placed at addresses that are multiples of their size.
•This improves the efficiency of memory access by the processor.
•Example: A struct in C containing an integer and a double may require padding to ensure each field is properly aligned.
Accessing Information

•Memory Addressing:
•Memory is accessed using addresses, which are numerical identifiers for specific locations in memory.
•Pointer: A variable that stores the address of another variable. Pointers are used to manipulate memory
directly.
•Pointer Arithmetic:
•Pointer arithmetic allows for efficient memory access in languages like C.
•Example: arr[i] → *(arr + i), where arr is a pointer to the first element of the array.
•Virtual Memory:
•Most modern systems use virtual memory: a system where programs use more memory than
physically available, by swapping data to and from disk.
Arithmetic and Logical Operations

•Arithmetic Operations:
•Addition, subtraction, multiplication, and division using integer and floating-point representations.
•Floating-Point Arithmetic: Operations can lead to rounding errors due to the limited precision of
floating-point representations.
•Logical Operations:
•AND, OR, NOT, and XOR are used for bitwise operations.
•Example: 0110 AND 1100 → 0100.
•Applications:
•Logical operations are used in control flow (conditional statements) and in manipulating bit patterns.

You might also like