Wednesday, September 17, 2025

SS2 Computer Science First Term Lesson Note

 

Central Processing Unit (CPU)

The Central Processing Unit (CPU) also called microprocessor, computer processor or simply processor is the main part of a computer that carries out all the instructions of a program.

It is often called the “brain of the computer” because it controls all the operations, processes data, and manages communication between the computer’s hardware and software.

In simple terms, the CPU carry out the following functions:

  1. Fetches instructions from memory.
  2. Decodes them to understand what action is needed.
  3. Executes the instructions.
  4. Stores the results back in memory if needed.

 

The central processing unit (CPU) carries out each function or instruction in sequence. The CPU is located on the motherboard, and all of its functions are handled by a component called the chip or microprocessor. The CPU is the most important part of a computer, regardless of its size. It controls everything—from the operating system and software to games and hardware.

The CPU is responsible for instructing the computer on what to do and when, such as connecting to the internet or writing a document. It performs all the analytical, computational, and logical operations that occur within the computer.

CPU speed is measured in cycles per second, which determines how quickly it can execute instructions. This is commonly referred to as clock speed. The more cycles the CPU performs per second, the more instructions it can process, and the faster the computer operates.

The first Intel CPU operated at a speed of 108 kHz, or 108,000 cycles per second. Today, however, CPUs are far more powerful, with speeds reaching as high as 3.5 GHz—or 3.5 billion cycles per second.

Types of CPU

CPU can be group by the Number of Cores as follows:

·         Single-core CPU → one processing unit; older and slower at multitasking.

·         Dual-core CPU → two cores in one chip; can handle more tasks at once.

·         Quad-core CPU → four cores, common in modern PCs.

·         Hexa-core, Octa-core, Deca-core → 6, 8, or 10 cores; found in high-performance computers and smartphones.

·         Multi-core CPUs → general term for CPUs with multiple cores, used in servers and powerful workstations.

 

 

Components of the CPU

The main components of the CPU (Central Processing Unit) are:

 

1.      Arithmetic and Logic Unit (ALU) – performs all arithmetic (addition, subtraction, etc.) and logical operations (comparisons like greater than, equal to, etc.).

2.      Control Unit (CU) – directs the flow of data and instructions, coordinating the activities of all parts of the computer.

3.      Registers – Registers are a type of internal CPU memory. It is the smallest and fastest type of memory inside the CPU, used to hold instructions, addresses, or data that the processor is actively working on. Data only stays there while being processed.

Other components are:

1.      Cache Memory –Cache is a small, high-speed memory located inside or very close to the CPU, used to store frequently used data and instructions so the processor can retrieve them faster than from RAM.

The Cache is an Intermediate memory between registers and RAM. It is larger and slower than registers but faster and smaller than RAM .

The level of cache are: L1 (smallest, fastest, built into CPU core), L2 (larger, slightly slower), L3 (even larger, shared across cores).

The cache is a Volatile memory: like RAM, cache is cleared when power is turned off.

 

2.      Clock – provides timing signals that synchronize all operations of the CPU.



Functions of the Arithmetic and Logic Unit

The Arithmetic and Logic Unit (ALU) is the part of the CPU responsible for all calculations and decision-making. Its main functions are:

  1. Arithmetic operations – carries out mathematical operations such as addition, subtraction, multiplication, and division.
  2. Logic operations – performs comparisons like equal to (=), greater than (>), less than (<), and not equal to (≠).
  3. Bitwise operations – manipulates data at the binary (bit) level, such as shifting bits left/right or AND, OR, NOT operations.
  4. Decision-making support – helps the CPU decide the next step in processing based on logical test results (e.g., if a condition is true or false).
  5. Data transfer operations – temporarily moves data between registers or to/from memory during processing.

Functions of the Control Unit (CU):

  1. Instruction Fetching – retrieves instructions from the main memory.
  2. Instruction Decoding – interprets (decodes) the instructions to understand what action is required.
  3. Control of Data Flow – directs the movement of data between the CPU, memory, and input/output devices.
  4. Coordination of Components – ensures that the ALU, registers, and other components work together in the right order.
  5. Execution Control – tells the ALU when to perform operations and ensures results are stored in the correct place.
  6. Maintains Sequence – ensures instructions are executed step by step in the proper sequence unless told otherwise (like in jumps or loops).

 

The Register: Registers are small, high-speed storage units inside the CPU that keep track of instructions, data, addresses, and results during processing.

Functions of Registers in the CPU:

  1. Temporary Storage – hold data, instructions, and memory addresses being used by the CPU.
  2. Fast Access – provide very quick read/write access compared to main memory (RAM).
  3. Instruction Holding – keep the current instruction being executed (e.g., in the Instruction Register).
  4. Address Holding – store the address of the next instruction or data in memory (e.g., Program Counter, Memory Address Register).
  5. Data Holding – store data being transferred to/from memory or the ALU (e.g., Memory Data Register, Accumulator).
  6. Control Information – some registers hold status flags that show the result of operations (e.g., zero, carry, overflow, negative).

 

Types of registers in the CPU and their functions

1.      Program Counter (PC)

    • Holds the address of the next instruction to be executed.
    • Updates automatically after each instruction.

2.      Instruction Register (IR): Stores the current instruction that the CPU is decoding and executing.

3.      Memory Address Register (MAR): Holds the address in memory where data or an instruction needs to be fetched or stored.

4.      Memory Data Register (MDR) (also called Memory Buffer Register, MBR)

    • Temporarily holds the data being transferred to or from memory.

5.      Accumulator (ACC)

    • Stores intermediate arithmetic and logic results produced by the ALU.

6.      General Purpose Registers (e.g., AX, BX in older CPUs)

    • Used by the CPU to hold temporary data, variables, or intermediate results during processing.

7.      Status Register / Flag Register

    • Contains flags (bits) that show the results of operations, such as:
      • Zero flag (result is zero)
      • Carry flag (carry generated in addition)
      • Sign flag (positive/negative result)
      • Overflow flag (arithmetic overflow)



Memory Unit

The Memory Unit Is the part of a computer that stores data and instructions, either temporarily or permanently, for use by the CPU and other components. It stores instructions that the CPU needs to execute. The memory unit is made of internal memory which consist of the Register and the Cache and the external memory which consist of the main memory and the auxiliary memory

.

Functions of the Memory Unit in a computer

1.      Storage of Instructions – keeps the programs and instructions that the CPU will execute.

2.      Storage of Data – holds the data that is being processed by the CPU.

3.      Storage of Results – saves the output produced after processing, before sending it to output devices.

4.      Data Transfer – transfers data and instructions to and from the CPU as needed.

5.      Program Execution Support – ensures instructions are available in the correct sequence for execution.

Types of Memory

a.       Primary memory (Main Memory)

b.      Secondary memory (Auxiliary Memory)

 

a. Primary Memory: The Primary Memory also called main memory is the part of the memory unit that directly stores data and instructions the CPU needs while working.

The primary memory is fast much faster than secondary storage like hard drives and it is directly accessible by the CPU (the CPU fetches instructions and data from it).

Types of Primary Memory

1.      RAM (Random Access Memory)

2.      ROM (Read Only Memory)

 

1. RAM (Random Access Memory): This is a volatile memory used by computers to store data that the CPU needs quickly. It is connected to the CPU through a memory bus.

Key characteristics and function

1.      It is a temporary storage.

2.      It Stores data and instructions currently being used by the CPU.

3.      Volatile (data disappears when power is off).

4.      More RAM means more applications/data your system can handle at once without slowing down.

5.      Multiple apps stay open smoothly if enough RAM is available.

6.      Improves performance for games, video editing, and large file processing

Types of RAM

Main Categories of RAM are

a. DRAM (Dynamic RAM)

  • Made of memory cells which are composed of one capacitor and one transistor.
  • Stores each bit as a charge in a tiny capacitor.
  • Needs to be refreshed thousands of times per second in order to maintain data.
  • Cheap & high-density, but slower compared to other types.
  • Used in main system memory.

b. SRAM (Static RAM)

  • Retains its contents as long as the power is being supplied
  • Stores data using flip-flops (doesn’t need refreshing).
  • Faster and more reliable than DRAM.
  • Uses a matrix of 6-transistors and no capacitors
  • More expensive & lower density → not used for main memory.
  • Found in CPU caches (L1, L2, L3).

 

2.  ROM (Read Only Memory): This is a non-volatile (data stays even when power is off). It is traditionally pre-programmed with permanent instructions that cannot be modified (or only modified with special methods).

Key characteristics and functions

1.      Permanent storage.

2.      We can only read but cannot write on it.

3.      Stores essential programs like the BIOS needed to start the computer.

4.      Non-volatile (data stays even when power is off).

  1. Provides a permanent program for devices like printers, calculators, embedded systems.
  2. Ensures critical instructions are safe from being deleted or changed accidentally.

Types of ROM

  1. MROM (Masked ROM)
    • Data is written during manufacturing.
    • Cannot be changed later.
    • Cheap, but inflexible.
  2. PROM (Programmable ROM)
    • Can be written once by the user (with special hardware).
    • Once programmed, cannot be erased.
  3. EPROM (Erasable Programmable ROM)
    • Can be erased by UV light and reprogrammed.
    • Reusable, but slow and inconvenient.
  4. EEPROM (Electrically Erasable Programmable ROM)
    • Can be erased and reprogrammed using electricity.
    • More flexible, often used for firmware updates.
  5. Flash Memory (a type of EEPROM)
    • Can be rewritten many times quickly.
    • Used in USB drives, SSDs, memory cards, BIOS chips.

 

 

Difference Between RAM and ROM

Feature

RAM (Random Access Memory)

ROM (Read Only Memory)

Nature

Temporary memory (volatile)

Permanent memory (non-volatile)

Data Retention

Data is lost when power is off

Data is retained even when power is off

Function

Stores data and instructions the CPU is currently using

Stores essential programs and instructions needed for booting (e.g., BIOS)

Read/Write

Both read and write operations are possible

Usually read-only (cannot be modified easily)

Speed

Very fast

Slower compared to RAM

Data input

The data is usually inputed by the manufacturer.

The data is usually inputted by the user

Example Use

Running applications, files in use, active processes

Boot-up firmware, embedded system instructions

 

 

Difference between Registers and Main Memory

Feature

Registers

Main Memory (Primary Memory – RAM/ROM)

Location

Inside the CPU.

Outside the CPU but directly connected to it.

Speed

Extremely fast (fastest storage in the computer).

Fast, but slower than registers.

Size/Capacity

Very small (measured in bits or bytes).

Much larger (measured in GBs).

Function

Holds instructions, addresses, or data that the CPU is currently processing.

Stores programs, data, and instructions that the CPU may need.

Accessibility

Directly accessed by the CPU without delay.

CPU must fetch data from main memory, which takes more time.

Volatility

Volatile (contents lost when power is off).

RAM is volatile, ROM is non-volatile.

 

 

b.      Secondary Memory

The Secondary Memory (also called auxiliary storage or external memory) is the type of computer memory used to store data, programs, and files permanently for long-term use.

Key characteristics and functions

1.      Non-volatile – data is not lost when the power is turned off.

2.      Larger in capacity – can store much more data than primary memory.

3.      Slower in speed – accessing data takes more time compared to RAM.

4.      Not directly accessed by the CPU – data must first be loaded into primary memory before the CPU can use it.

5.      Keeps data and programs even when the computer is turned off (non-volatile).

6.      Stores copies of important files to protect against data loss.

7.      Large Capacity Storage: Holds much more data than primary memory (RAM).

8.      Allows files to be moved between devices (e.g., flash drives, memory cards).

9.      Preserves data for long-term use, especially with media like magnetic tapes and optical discs.

 

Examples of Secondary Memory:

 

Here’s a brief description of each secondary storage device:

  1. Hard Disk Drives (HDDs) – Magnetic storage devices with spinning platters and read/write heads; they offer large capacity at low cost but are slower and more fragile compared to SSDs.
  2. Solid State Drives (SSDs) – Use flash memory (no moving parts) to store data; they are much faster, more durable, and energy-efficient than HDDs, but generally more expensive per GB.
  3. Optical Discs (CDs, DVDs, Blu-ray) – Use lasers to read/write data on discs; mainly used for media distribution and backup, but less common today due to limited capacity and slower speeds.
  4. Flash Drives / Pen Drives – Portable USB-based flash memory devices; small, lightweight, and convenient for transferring files between computers.
  5. Memory Card – Small flash memory storage used mainly in smartphones, cameras, and other portable devices; compact and easily removable.
  6. Magnetic Tapes – Long strips of magnetic material used for sequential data storage; very high capacity and cost-effective for backups and archiving, though slower to access.

 

Comparison Between Primary Memory and Secondary Memory

Feature

Primary Memory

Secondary Memory

Definition

The computer’s main memory directly accessed by the CPU.

External/permanent storage used for long-term data storage.

Types

RAM (volatile), ROM (non-volatile).

Hard disks, SSDs, CDs, DVDs, USB drives, memory cards, etc.

Volatility

Mostly volatile (RAM loses data when power is off).

Non-volatile (data is retained even without power).

Speed

Very fast (directly works with CPU).

Slower compared to primary memory.

Capacity

Smaller (usually measured in GBs).

Much larger (can be in TBs).

Usage

Stores data and instructions currently in use.

Stores data, software, and files permanently.

Direct CPU Access

Yes, CPU can directly fetch data from it.

No, data must be transferred into primary memory first.

 

 

Unit of Storage

The Unit of Storage refers to the basic measurement used to describe the size or capacity of computer memory and storage devices. It tells us how much data a storage medium can hold.

In other words a unit of storage is a way of measuring how much information can be stored in memory or on a device,

Common Units of Storage:

  • Bit (b) → the smallest unit of data, either 0 or 1.
  • Nibble → 4 bits.
  • Byte (B) → 8 bits (enough to store one character, e.g., “A”).
  • Kilobyte (KB) = 1024 Bytes.
  • Megabyte (MB) = 1024 KB.
  • Gigabyte (GB) = 1024 MB.
  • Terabyte (TB) = 1024 GB.
  • Petabyte (PB) = 1024 TB.
  • Exabyte (EB) = 1024 PB.


Conversion from one storage unit to another

We can convert from one unit of storage to another. This is done through the following process

  • To go up (KB → MB → GB → TB), divide by 1024.
  • To go down (TB → GB → MB → KB), multiply by 1024.

Example 1: Convert 2048 KB to MB

Solution

Since we are moving from small unit to large unit, we divide

2048 ÷ 1024 = 2 MB

Example 2: Convert 3 GB to MB

Solution

Since we are moving from large unit to small unit, we multiply

3 × 1024 = 3072 MB

 

Example 3 Convert 5 GB to KB
To perform this conversion, you multiply by 1024 twice, first convert to megabytes from gigabyte and from megabyte to kilobytes.

The calculation is as follows: 5 GB×1024 MB/GB=5120 MB

5120 MB×1024 KB/MB=5,242,880 KB

Home works

  1. Convert 8192 KB to MB.
  2. Convert 5 GB to MB.
  3. Convert 2 TB to GB.
  4. Convert 512 MB to GB.
  5. Convert 1,048,576 KB to GB.
  6. Convert 4 TB to MB.
  7. Convert 256 Bytes to Bits.
  8. Convert 64 GB to TB.
  9. Convert 131,072 KB to MB.

 

 

Comparison of Auxiliary Storage Devices

Device

Size / Portability

Memory Capacity

Speed

Technology

Typical Use

Hard Disk Drive (HDD)

Medium, not very portable (internal or external)

High (hundreds of GB to several TB)

Moderate (mechanical, slower than SSD)

Magnetic storage with spinning disks

Storing OS, software, and large files

Solid State Drive (SSD)

Small to medium, portable (internal or external)

High (hundreds of GB to several TB)

Very fast (uses flash memory, no moving parts)

Flash-based electronic storage

Faster boot-up, apps, gaming, modern laptops

Optical Discs (CD/DVD/Blu-ray)

Small, portable

Low–Medium (CD ~700 MB, DVD ~4.7–8.5 GB, Blu-ray ~25–50 GB)

Slow (requires disc drive)

Laser technology (optical storage)

Movies, music, software distribution

USB Flash Drive (Pen Drive)

Very small, highly portable

Medium–High (2 GB up to 1 TB)

Fast (USB 3.0/3.1 very quick)

Flash memory

File transfer, backups, portable storage

Memory Cards (SD, microSD)

Very small, portable

Medium (up to 1 TB in modern cards)

Fast (depends on class/speed rating)

Flash memory

Cameras, smartphones, tablets

Magnetic Tape

Large cartridges, not portable for everyday use

Very high (up to multiple TB per tape)

Slow (sequential access only)

Magnetic tape reels

Backup and archival storage for organizations

 

 

 

 

 

 

 

No comments:

Post a Comment

SS2 Data Processing First Term Lesson Note

    DATA MODEL A model is like a blueprint of a more complex real-world object or event.   A data model is a visual blueprint that ...