Notes, summaries, assignments, exams, and problems for Computers

Sort by
Subject
Level

CPU Registers: Functions, Types, and Architecture

Posted by Anonymous and classified in Computers

Written on in English with a size of 3.31 KB

What Are CPU Registers?

Registers are very small but very fast memory units located inside the CPU. They are used to store data temporarily during the execution of instructions.

Whenever the CPU processes operations like addition, subtraction, or fetching data from memory, it uses registers to hold the data in between. You can imagine registers like a small notepad that the CPU uses to write down important information while working.

They are much faster than RAM and closer to the processing unit, allowing the CPU to read and write from registers instantly without wasting any time.

Types of CPU Registers

The CPU contains different types of registers, each with a unique function.

1. Accumulator (ACC)

  • This register is used to store the results of arithmetic
... Continue reading "CPU Registers: Functions, Types, and Architecture" »

Transport Layer Functions and TCP Flow Control Explained

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.5 KB

The Transport Layer: OSI Model Layer 4

The Transport Layer is the 4th layer of the OSI model, providing process-to-process communication between applications running on different hosts. It ensures reliable, error-free, and ordered delivery of data.

Main Services of the Transport Layer

  • Process-to-Process Delivery: Uses port numbers to deliver data from a specific process on the sender to a specific process on the receiver.
  • Segmentation and Reassembly: Divides large messages into smaller segments for transmission and reassembles them at the destination.
  • Connection Control: Supports connection-oriented communication (TCP) and connectionless communication (UDP).
  • Flow Control: Prevents the sender from overwhelming the receiver with too much data by using
... Continue reading "Transport Layer Functions and TCP Flow Control Explained" »

Network Congestion Control and Traffic Shaping

Posted by Anonymous and classified in Computers

Written on in English with a size of 6 KB

Network Layer Design Issues

The network layer involves several critical design considerations, including store-and-forward switching, transport-layer services, the distinction between Virtual Circuits (VC) and Datagrams, and congestion management.

Understanding Network Congestion

Congestion occurs when too much traffic enters the network, leading to overloaded routers and a sharp drop in overall performance.

Congestion Control vs Flow Control

  • Congestion Control: A global issue involving all routers and hosts to manage total network load.
  • Flow Control: A point-to-point mechanism ensuring a sender does not overwhelm a specific receiver.

General Principles of Congestion Management

  1. Monitor the system to detect where and when congestion occurs.
  2. Distribute
... Continue reading "Network Congestion Control and Traffic Shaping" »

Java Network Programming: Server Implementation Patterns

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.1 KB

Thread Pool Server Implementation

ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
try (ServerSocket serverSocket = new ServerSocket(4444)) {
    while (true) {
        System.out.println("\n Listening for a client connection");
        Socket socketForClient = serverSocket.accept();
        System.out.println("\n New connection accepted: " + socketForClient.getRemoteSocketAddress());
        WorkerThread task = new WorkerThread(socketForClient);
        System.out.println("Task created: " + task);
        executor.submit(task);
    }
}

public WorkerThread(Socket socketForClient) {
    this.socketForClient = socketForClient;
}

Network Programming MCQ Answers

  • Q4: The interest set defines what operations the
... Continue reading "Java Network Programming: Server Implementation Patterns" »

Linux Shell Programming with Bash and the vi Editor

Posted by Anonymous and classified in Computers

Written on in English with a size of 6.71 KB

🐚 Introduction to Shell Programming in Linux

Shell programming is the process of writing shell scripts—sequences of commands executed by the command-line interpreter (the shell, typically Bash) to automate tasks. It leverages command-line utilities, variables, and control flow structures to create powerful programs.

✍️ The vi Editor

The vi (or vim) editor is a text-based, modal editor crucial for writing shell scripts and editing configuration files in Linux. It operates in distinct modes:

ModeFunctionKey Commands
Command ModeThe default mode used for navigation, deletion, copying, and pasting.h, j, k, l for cursor movement; dd to delete a line.
Insert ModeUsed for typing and editing text.i (insert before cursor), a (append after cursor)
... Continue reading "Linux Shell Programming with Bash and the vi Editor" »

Mastering Relational Algebra for Database Queries

Classified in Computers

Written on in English with a size of 4.53 KB

Relational Algebra Fundamentals

  • Relational Algebra is a mathematical query language used in databases.
  • The result of any operation is always another relation (table).

Relational Algebra Operations Explained

Unary Relational Operations

SELECT (σ) – Filters Rows

  • Retrieves specific rows from a table based on a condition.
  • Syntax: σ (condition) (Relation)
  • Example: σ (Dept_ID = 4) (EMPLOYEE)

PROJECT (π) – Filters Columns

  • Retrieves specific columns from a table.
  • Syntax: π (column1, column2) (Relation)
  • Example: π (Name, Salary) (EMPLOYEE)

RENAME (ρ) – Changes Table or Column Name

  • Syntax: ρ (NewTable (NewColumn1, NewColumn2), OldTable)
  • Example: ρ (Staff (Emp_ID, FullName), EMPLOYEE)

Set Theory Operations

UNION (∪) – Combines Two Tables

  • Combines tuples
... Continue reading "Mastering Relational Algebra for Database Queries" »

C Programming: Tokens, Operators, and Logic

Classified in Computers

Written on in English with a size of 2.55 KB

Tokens

In programming, a token is the smallest meaningful element in code. They are the building blocks of a language's syntax. Common token types include:

  • Keywords: Reserved words like if, else, while, and int (for declaring integers).
  • Identifiers: Names given to elements like variables (e.g., sum), functions, and arrays.
  • Constants: Unchanging values during program execution (e.g., 3.14 for pi).
  • Operators: Symbols for mathematical or logical operations (e.g., + for addition).
  • Separators: Punctuation like commas (,), semicolons (;), and braces ({}).

Example: int sum = 10 + 5;

In this line, int is a keyword, sum is an identifier, = is an operator, 10 and 5 are constants, and ; is a separator.

Arithmetic Operators

C has nine arithmetic operators for basic... Continue reading "C Programming: Tokens, Operators, and Logic" »

Python Fundamentals: Variables, Data Types, and Control Flow

Posted by Anonymous and classified in Computers

Written on in English with a size of 14.36 KB

Keywords and identifiers are fundamental elements in programming languages used to define variables, functions, and other constructs, with keywords being reserved words that have special meanings, and identifiers being names given to user-defined entities.

Comments in programming serve the essential purpose of making the source code more understandable and maintainable by providing textual annotations that explain the logic, purpose, or any additional information about the code. They help programmers and collaborators to read, debug, and update the code efficiently without affecting its execution.

There are two main types of comments:
- Single-line comments start with specific symbols like // in languages such as C, Java, and JavaScript, and they... Continue reading "Python Fundamentals: Variables, Data Types, and Control Flow" »

Polymorphism in C++: Concepts and Methods Explained

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.99 KB

Polymorphism in C++

Polymorphism is a fundamental pillar of Object-Oriented Programming (OOP). The term is derived from two Greek words: Poly (many) and Morph (forms). Therefore, polymorphism signifies one name having many forms.

In C++, polymorphism enables the same function or operator to perform different operations depending on the context.

Why Use Polymorphism?

  • Improves code flexibility
  • Reduces complexity
  • Increases readability
  • Supports code reuse
  • Facilitates generic programming

Types of Polymorphism in C++

Polymorphism in C++ is categorized into two primary types:

1. Compile-Time (Static) Polymorphism

Compile-time polymorphism is resolved during the compilation phase. The compiler determines which function to invoke based on the function definition.... Continue reading "Polymorphism in C++: Concepts and Methods Explained" »

Mastering Process Synchronization: Critical Sections and Semaphores

Posted by Anonymous and classified in Computers

Written on in English with a size of 7.56 KB

The Critical Section Problem

In a multi-threaded or multi-process system, shared data can easily become corrupted if multiple processes try to modify it at the same time. This issue is known as a race condition.

To prevent this, we identify the section of code where shared resources are accessed as the Critical Section. The goal is to ensure that only one process executes in its critical section at any given moment.

do {
    [ Entry Section ]   <-- Request permission to enter
        Critical Section   <-- Manipulate shared data
    [ Exit Section ]    <-- Release permission
        Remainder Section  <-- Non-shared code
} while (true);

To be a valid solution, any mechanism managing the critical section must satisfy three strict requirements:... Continue reading "Mastering Process Synchronization: Critical Sections and Semaphores" »