General Terms in computer science

Memory hierarchy of a computer with the help of a diagram.

The memory hierarchy in a computer is the arrangement of storage devices in order of speed, cost, and capacity.
The hierarchy helps achieve high performance at a reasonable cost by using small, fast memories close to the CPU and larger, slower memories farther away.

Levels of Memory Hierarchy

  1. Registers
    • Smallest and fastest memory.
    • Located inside the CPU.
    • Stores immediate data and instructions for processing.
  2. Cache Memory
    • Very fast memory is located between the CPU and main memory.
    • Stores frequently use instructions and data.
    • Reduces access time to the main memory.
  3. Main Memory (RAM)
    • Stores programs and data currently being used.
    • Faster than secondary storage but slower than cache.
  4. Secondary Memory
    • Permanent storage such as hard disks and SSDs.
    • Used for long-term storage of programs and data.
  5. Tertiary / Backup Storage
    • Includes optical disks, magnetic tapes, etc.
    • Used for backup and archival storage.

Memory Hierarchy Diagram

Fastest / Smallest / Costliest

 

Registers
Cache
RAM
Storage
Tertiary Storage

Slowest / Largest / Cheapest

Key Points

  • Speed decreases from top to bottom.
  • Storage capacity increases from top to bottom.
  • Cost per bit decreases from top to bottom.

Compiler and Interpreter.

 

Feature Compiler Interpreter
Translation Translates the entire program at once. Translates the program line by line.
Execution Speed Program executes faster after compilation. Program executes slower because translation happens during execution.
Error Detection Shows all errors after compiling the whole program. Shows errors one by one during execution.
Object Code Generates object code or executable file. Does not produce object code.
Program Execution Program must be compiled first and then executed. Program is executed directly without separate compilation.
Example Languages C, C++, Go Python, JavaScript, Ruby

Summary

  • A compiler converts the entire source code into machine code before execution.
  • An interpreter converts and executes the program one statement at a time.

 

Von Neumann architecture

 The John von Neumann architecture is a computer design model proposed in 1945. It forms the basis of most modern computers. The main idea is that program instructions and data are stored in the same memory.

Main Components

  1. Input Unit
    Accepts data and instructions from the user and sends them to the computer.
  2. Memory Unit
    Stores data, instructions, and intermediate results during processing.
  3. Control Unit (CU)
    Directs and coordinates all operations of the computer. It fetches instructions from memory and controls their execution.
  4. Arithmetic Logic Unit (ALU)
    Performs arithmetic operations (addition, subtraction, multiplication, division) and logical operations (comparison, AND, OR, NOT).
  5. Output Unit
    Displays or prints the processed results to the user.

Working Principle

The architecture follows the Fetch–Decode–Execute cycle:

  1. Fetch – The control unit fetches an instruction from memory.
  2. Decode – The instruction is decoded to determine the operation.
  3. Execute – The ALU performs the operation and stores the result.

Advantages

  • Simple and easy to design.
  • Instructions and data share the same memory, making programming easier.
  • Efficient for general-purpose computing.

Limitation

  • Von Neumann bottleneck: Since data and instructions use the same bus, only one transfer can occur at a time, which may slow down processing.

System software and Application software.

 

Basis System Software Application Software
Meaning Software that manages and controls the computer hardware and provides a platform for other programs. Software designed to help users perform specific tasks.
Purpose To operate and control the computer system. To solve user-oriented problems or perform specific work.
User Interaction Works mostly in the background and is not directly used by the user. Directly used by the user.
Dependency Application software depends on system software to run. Cannot run without system software.
Examples Microsoft Windows, Linux, device drivers, language translators Microsoft Word, Microsoft Excel, Adobe Photoshop

In simple terms:

  • System software keeps the computer running smoothly.
  • Application software helps the user do useful work like writing, calculating, or drawing.

ALU and CU

  1. Arithmetic Logic Unit (ALU)

The ALU performs all the calculations and logical decisions in a computer.

Functions of ALU:

  • Arithmetic operations: Performs mathematical calculations such as addition, subtraction, multiplication, and division.
  • Logical operations: Compares values using logical operators like AND, OR, NOT.
  • Comparison operations: Determines relationships such as greater than, less than, or equal to.
  • Bitwise operations: Manipulates binary data at the bit level.
  • Intermediate results: Stores temporary results during processing before sending them to memory or registers.

Think of the ALU as the computer’s mathematician and decision maker.

  1. Control Unit (CU)

The CU acts as the manager of the CPU, directing how data and instructions move inside the computer.

Functions of CU:

  • Fetches instructions from the main memory.
  • Decodes instructions to understand what operation needs to be performed.
  • Controls the execution of instructions by sending signals to the ALU, memory, and input/output devices.
  • Coordinates data flow between the CPU, memory, and other hardware components.
  • Maintains the sequence of operations during program execution.

If the ALU is the calculator, the CU is the orchestra conductor, ensuring every component performs at the right moment.

In short:

  • ALU: Performs calculations and logical comparisons.
  • CU: Controls and coordinates all operations of the computer.

Five important registers in CPU and the purpose of each register.

The CPU (Central Processing Unit) contains several registers that store data and instructions temporarily during program execution.

Five Important Registers in CPU

Register Purpose
Program Counter (PC) Stores the address of the next instruction to be executed.
Instruction Register (IR) Holds the current instruction that is being executed by the CPU.
Memory Address Register (MAR) Stores the address of the memory location from which data or instructions are to be fetched or stored.
Memory Data Register (MDR) (or MBR) Holds the data being transferred to or from memory.
Accumulator (ACC) Stores intermediate results of arithmetic and logical operations performed by the ALU.

Summary

These registers help the CPU fetch, decode, and execute instructions efficiently by temporarily storing addresses, data, and intermediate results.

 

Modular Programming

Modular programming is a programming technique in which a large program is divided into smaller independent modules or functions, each performing a specific task.

Advantages of Modular Programming

  1. Easy to Understand
    Dividing a large program into smaller modules makes the program simpler and easier to understand.
  2. Easy Debugging
    Errors can be identified and corrected easily because each module can be tested separately.
  3. Code Reusability
    Modules or functions can be reused in other programs, saving time and effort.
  4. Easy Maintenance
    Changes can be made in one module without affecting the entire program.
  5. Improved Program Development
    Different programmers can work on different modules simultaneously, speeding up development.
  6. Better Program Organization
    The program becomes well-structured and systematic.

Summary

Modular programming improves readability, debugging, maintenance, and reusability, making large programs easier to develop and manage.